摘要: 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 阅读(244) 评论(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 阅读(241) 评论(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 阅读(201) 评论(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 阅读(275) 评论(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 阅读(198) 评论(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 阅读(307) 评论(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 阅读(911) 评论(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 阅读(375) 评论(0) 推荐(0)