上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 20 下一页
摘要: The recursive solution is trivial and I omit it here.Iterative Solution using Stack (O(n)time andO(n)space): 1 /** 2 * Definition of TreeNode: 3 * c... 阅读全文
posted @ 2015-06-29 17:08 jianchao-li 阅读(219) 评论(0) 推荐(0) 编辑
摘要: A subroutine of merge sort. 1 class Solution { 2 public: 3 /** 4 * @param A and B: sorted integer array A and B. 5 * @return: A new sort... 阅读全文
posted @ 2015-06-29 16:44 jianchao-li 阅读(261) 评论(0) 推荐(0) 编辑
摘要: The recursive solution is trivial and I omit it here.Iterative Solution using Stack (O(n)time andO(n)space): 1 /** 2 * Definition of TreeNode: 3 * c... 阅读全文
posted @ 2015-06-29 16:21 jianchao-li 阅读(227) 评论(0) 推荐(0) 编辑
摘要: The recursive solution is trivial and I omit it here.Iterative Solution using Stack (O(n) time and O(n) space): 1 /** 2 * Definition of TreeNode: 3 ... 阅读全文
posted @ 2015-06-29 15:38 jianchao-li 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 动态规划:lis[i] = max_{j = 0, 1, ..., i - 1, nums[j] nums) { 8 // write your code here 9 vector lis(nums.size(), 1);10 int maxlen... 阅读全文
posted @ 2015-06-29 15:32 jianchao-li 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param strs: A list of strings 5 * @return: The longest common prefix 6 */ 7 string... 阅读全文
posted @ 2015-06-29 15:25 jianchao-li 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Bit-by-Bit summation: 1 class Solution { 2 public: 3 /* 4 * @param a: The first integer 5 * @param b: The second integer 6 * @retur... 阅读全文
posted @ 2015-06-29 00:00 jianchao-li 阅读(663) 评论(0) 推荐(0) 编辑
摘要: The hints of the problem has given detailed information to implement the topological sorting algorithm. In fact, the toposort algorithm of the hint is... 阅读全文
posted @ 2015-06-28 23:44 jianchao-li 阅读(203) 评论(0) 推荐(0) 编辑
摘要: BFS: 1 /** 2 * Definition for Directed graph. 3 * struct DirectedGraphNode { 4 * int label; 5 * vector neighbors; 6 * DirectedGraphNo... 阅读全文
posted @ 2015-06-28 23:05 jianchao-li 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 基于快速排序: 1 class Solution { 2 public: 3 /* 4 * param k : description of k 5 * param nums : description of array and index 0 ~ n-1 6 ... 阅读全文
posted @ 2015-06-28 17:29 jianchao-li 阅读(652) 评论(1) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param grid: a list of lists of integers. 5 * @return: An integer, minimizes the sum of all numb... 阅读全文
posted @ 2015-06-28 17:22 jianchao-li 阅读(441) 评论(0) 推荐(1) 编辑
摘要: Well, to compute the number of trailing zeros, we need to first think clear about what will generate a trailing0? Obviously, a number multiplied by10w... 阅读全文
posted @ 2015-06-28 16:52 jianchao-li 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 // param n : description of n 4 // return: description of return 5 long long trailingZeros(long long n) ... 阅读全文
posted @ 2015-06-28 16:41 jianchao-li 阅读(220) 评论(0) 推荐(0) 编辑
摘要: Well, the basic idea is very simple. Start from the tail ofsand move backwards to find the first non-space character. Then from this character, move b... 阅读全文
posted @ 2015-06-28 16:11 jianchao-li 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param s A string 5 * @return the length of last word 6 */ 7 int lengthOfLastWord(strin... 阅读全文
posted @ 2015-06-28 15:57 jianchao-li 阅读(171) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 20 下一页