摘要: 基础教程:极客学院 实例教程: 国外教程,挺多实例的 蛮牛在线,太杂了,有基础也有重复,老师水平也不一样,教学风格不一样,语速不一样,得自己淘宝~ 泰客在线,挺多实例教程的 阅读全文
posted @ 2015-05-16 19:36 薇清浅 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题目: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 题意: 不用乘号、除号、取模运算来模拟除法。 分析: 一开始每回减去一次除数,这样会超时,优化是减去除数*2^n,用左移运算可以实现每次翻2倍. c... 阅读全文
posted @ 2015-03-13 07:37 薇清浅 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 思路1: class Solution { public: // 两个指针,p, q, q指向第二个,preP是p之前 ListNode *swapPairs(ListNode *head) { if(head == NULL) return NULL; auto p = head; auto q = head->next; ... 阅读全文
posted @ 2015-02-26 11:07 薇清浅 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题意: 将k个已排好序的链表合并为一个非下降排序的链表。 思路: 将每个链表的表头元素取出来,建立一个小顶堆,因为k个链表中都排好序了,因此每次取堆顶的元素就是k个链表中的最小... 阅读全文
posted @ 2015-02-26 10:21 薇清浅 阅读(6692) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such tha... 阅读全文
posted @ 2015-02-23 16:05 薇清浅 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding eleme... 阅读全文
posted @ 2015-02-15 15:21 薇清浅 阅读(1068) 评论(1) 推荐(0) 编辑
摘要: 题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 大意是:从所给的字符串s中找出其... 阅读全文
posted @ 2015-02-13 10:15 薇清浅 阅读(200) 评论(0) 推荐(0) 编辑
摘要: #define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__)#define CC_CALLBACK_1(__selector__,__target__, .... 阅读全文
posted @ 2015-01-25 09:33 薇清浅 阅读(5487) 评论(0) 推荐(0) 编辑
摘要: 思路:将两段最大的利润相加,一段的最大利润不一定只在一个上升期内,例如在绿线间就有两个上升区间 只要算出i之前的最大利润和i之后的最大利润相加就行,因为i不可能同时是峰值或者谷值,所以能保证不是在同一天买进和卖出 绿线的利润加上红线利润是最大利润。 class Solution { // 算出利润最大的两段 // 算出i之前最大的利润和i之后最大的利... 阅读全文
posted @ 2015-01-20 22:18 薇清浅 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 遍历价格vector,把每段上升期间的利润加起来,注意最后结束时记得再计算最后一次的利润 class Solution { // 把每段上升期间的利润加起来 // minVal: 低谷值 // maxVal: 峰值 // profit: 利润 public: int maxProfit(vector &prices) { ... 阅读全文
posted @ 2015-01-18 22:29 薇清浅 阅读(191) 评论(0) 推荐(0) 编辑