上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页
摘要: I guess some of you may have noticed that this seemingly simple problem has the lowest acceptance rate among all problems on the LeetCode OJ. Well, so... 阅读全文
posted @ 2015-07-11 14:37 jianchao-li 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Well, remember to take advantage of the property of binary search trees, which is,node -> left -> val val right -> val. Moreover, bothpandqwill be t... 阅读全文
posted @ 2015-07-11 13:50 jianchao-li 阅读(376) 评论(0) 推荐(0) 编辑
摘要: The suggested solution to this problem has given a clear idea. The tricky part of this problem is to handle all the edge cases carefully and write a c... 阅读全文
posted @ 2015-07-10 20:40 jianchao-li 阅读(159) 评论(0) 推荐(0) 编辑
摘要: The idea is not so obvious at first glance. Since you cannot move from a node back to its previous node in a singly linked list, we choose to reverse ... 阅读全文
posted @ 2015-07-10 13:40 jianchao-li 阅读(411) 评论(0) 推荐(0) 编辑
摘要: The key to this problem is to store the values in a stack. In the constructor and next, we add all the next smallest nodes into the stack. The followi... 阅读全文
posted @ 2015-07-08 14:20 jianchao-li 阅读(155) 评论(0) 推荐(0) 编辑
摘要: The following idea is taken from a book named 《剑指offer》 published in China.Supposen = 271, it then breaks[1, 271]into[1, 71]and[72, 271]. For[72, 271]... 阅读全文
posted @ 2015-07-08 01:50 jianchao-li 阅读(604) 评论(0) 推荐(0) 编辑
摘要: This is a classic problem of linked list. You may solve it using two pointers. The tricky part lies in the head pointer may also be the one that is re... 阅读全文
posted @ 2015-07-07 21:11 jianchao-li 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition of ListNode 3 * class ListNode { 4 * public: 5 * int val; 6 * ListNode *next; 7 * ListNode(int val) { 8 * ... 阅读全文
posted @ 2015-07-07 21:09 jianchao-li 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition of ListNode 3 * class ListNode { 4 * public: 5 * int val; 6 * ListNode *next; 7 * ListNode(int val) { 8 * ... 阅读全文
posted @ 2015-07-07 20:03 jianchao-li 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param A: a vector of integers 5 * @return: an integer 6 */ 7 int firstMissingPosit... 阅读全文
posted @ 2015-07-07 16:10 jianchao-li 阅读(256) 评论(0) 推荐(0) 编辑
摘要: This link has a nice explanation of the problem. I rewrite the code below. Play with it using some special examples and you will find out how it works... 阅读全文
posted @ 2015-07-07 12:46 jianchao-li 阅读(177) 评论(0) 推荐(0) 编辑
摘要: A classic interview question. This link has a nice explanation of the idea using two stacks and its amortized time complexity.I use the same idea in m... 阅读全文
posted @ 2015-07-07 11:54 jianchao-li 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 递归实现: 1 class Solution { 2 public: 3 /** 4 * @param nums: A list of integers. 5 * @return: A list of unique permutations. 6 */ 7 ... 阅读全文
posted @ 2015-07-07 01:23 jianchao-li 阅读(890) 评论(0) 推荐(0) 编辑
摘要: 递归实现:class Solution {public: /** * @param nums: A list of integers. * @return: A list of permutations. */ vector > permute(vector nu... 阅读全文
posted @ 2015-07-07 01:15 jianchao-li 阅读(343) 评论(0) 推荐(0) 编辑
摘要: I think the following code is self-explanatory enough. We use anunordered_map countsto record the expected times of each word and anotherunordered_map... 阅读全文
posted @ 2015-07-06 22:32 jianchao-li 阅读(215) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页