上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 20 下一页
摘要: Well, an interesting problem. If you draw some examples on a white board and try to figure out the regularities, you may have noticed that the key to ... 阅读全文
posted @ 2015-07-14 21:35 jianchao-li 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Well, since we need to make a deep copy of the list and nodes in the list have arandom pointer that may point to any node in the list (or NULL), we ne... 阅读全文
posted @ 2015-07-14 12:35 jianchao-li 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionGiven a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s =“eceba... 阅读全文
posted @ 2015-07-14 12:13 jianchao-li 阅读(240) 评论(0) 推荐(0) 编辑
摘要: The key to this problem is to identify all the words that can be added to a line and then identify the places that require an additional space (to mak... 阅读全文
posted @ 2015-07-14 02:22 jianchao-li 阅读(234) 评论(0) 推荐(0) 编辑
摘要: An interesting problem! But not very easy at first glance. You need to think very clear about how will a keypoint be generated. Since I only learn fro... 阅读全文
posted @ 2015-07-13 23:10 jianchao-li 阅读(1720) 评论(0) 推荐(0) 编辑
摘要: Well, a follow-up for the problemLowest Common Ancestor of a Binary Search Tree. However, this time you cannot figure out which subtree the given node... 阅读全文
posted @ 2015-07-13 15:36 jianchao-li 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Use the strs[0] as the reference string and then compare it with the remaining strings from left to right. Once we find a string with length less than... 阅读全文
posted @ 2015-07-12 13:57 jianchao-li 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Well, a typical backtracking problem. The code is as follows. You may walk through it using the example in the problem statement to see how it works. ... 阅读全文
posted @ 2015-07-11 23:12 jianchao-li 阅读(155) 评论(0) 推荐(0) 编辑
摘要: This problem has a very easy recursive code as follows. 1 class Solution { 2 public: 3 bool hasPathSum(TreeNode* root, int sum) { 4 if (!r... 阅读全文
posted @ 2015-07-11 22:38 jianchao-li 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param nums: a vector of integers 5 * @return: an integer 6 */ 7 int findMissing(ve... 阅读全文
posted @ 2015-07-11 21:32 jianchao-li 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for a point. 3 * struct Point { 4 * int x; 5 * int y; 6 * Point() : x(0), y(0) {} 7 * Point(int a, int b) ... 阅读全文
posted @ 2015-07-11 21:28 jianchao-li 阅读(1105) 评论(0) 推荐(0) 编辑
摘要: This problem has a naive idea, which is to traverse all possible pairs of two points and see how many other points fall in the line determined by them... 阅读全文
posted @ 2015-07-11 21:21 jianchao-li 阅读(349) 评论(0) 推荐(0) 编辑
摘要: A simple application of level-order traversal. Just push the last node in each level into the result.The code is as follows. 1 class Solution { 2 publ... 阅读全文
posted @ 2015-07-11 18:12 jianchao-li 阅读(234) 评论(0) 推荐(0) 编辑
摘要: The problem becomes more difficult once the binary tree is not perfect. The idea is still similar to use a level-order traversal. Note that we do not ... 阅读全文
posted @ 2015-07-11 18:00 jianchao-li 阅读(174) 评论(0) 推荐(0) 编辑
摘要: The idea is similar to a level-order traversal and remember to take full advantages of the prefect binary tree assumption in the problem statement.The... 阅读全文
posted @ 2015-07-11 17:00 jianchao-li 阅读(198) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 20 下一页