随笔分类 -  LintCode Solutions

Solutions to problems on http://www.lintcode.com/zh-cn/problem/.
摘要:动态规划: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) 编辑
摘要: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 阅读(653) 评论(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 阅读(442) 评论(0) 推荐(1) 编辑
摘要: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) 编辑
摘要: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 class Solution { 2 public: 3 /** 4 * @param s A string 5 * @return Whether the string is a valid palindrome 6 */ 7 bool isPa... 阅读全文
posted @ 2015-06-28 15:48 jianchao-li 阅读(229) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 /** 4 * @param s A string 5 * @return whether the string is a valid parentheses 6 */ 7 bool isV... 阅读全文
posted @ 2015-06-28 15:39 jianchao-li 阅读(477) 评论(0) 推荐(0) 编辑
摘要:递归实现: 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int v... 阅读全文
posted @ 2015-06-28 15:26 jianchao-li 阅读(496) 评论(0) 推荐(0) 编辑
摘要:1 class MinStack { 2 public: 3 MinStack() { 4 // do initialization if necessary 5 } 6 7 void push(int number) { 8 // wri... 阅读全文
posted @ 2015-06-28 15:21 jianchao-li 阅读(453) 评论(0) 推荐(0) 编辑
摘要:1 class Queue { 2 public: 3 stack stack1; 4 stack stack2; 5 6 Queue() { 7 // do intialization if necessary 8 } 9 10 void... 阅读全文
posted @ 2015-06-28 15:20 jianchao-li 阅读(282) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 /** 4 * @param A, B: Two strings. 5 * @return: The length of longest common subsequence of A and B. 6 ... 阅读全文
posted @ 2015-06-28 15:19 jianchao-li 阅读(162) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 /** 4 * @param A, B: Two string. 5 * @return: the length of the longest common substring. 6 */ ... 阅读全文
posted @ 2015-06-28 15:18 jianchao-li 阅读(183) 评论(0) 推荐(0) 编辑