2017年11月5日

摘要: class Solution {public: /* * @param n: non-negative integer, n posts * @param k: non-negative integer, k colors * @return: an integer, the total numbe 阅读全文
posted @ 2017-11-05 23:17 叶尘 阅读(119) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param A: An array of Integer * @return: an integer */ int longestIncreasingContinuousSubsequence(vector<int> &A) { // wr 阅读全文
posted @ 2017-11-05 23:16 叶尘 阅读(90) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param obstacleGrid: A list of lists of integers * @return: An integer */ int uniquePathsWithObstacles(vector<vector<int> 阅读全文
posted @ 2017-11-05 23:13 叶尘 阅读(106) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param m: positive integer (1 <= m <= 100) * @param n: positive integer (1 <= n <= 100) * @return: An integer */ int uniq 阅读全文
posted @ 2017-11-05 23:10 叶尘 阅读(112) 评论(0) 推荐(0)
 
摘要: 当爬第k阶楼梯时,有可能是从第k-1或k-2阶楼梯上过去的,所以到达第k阶楼梯的方法为到达第k-1与k-2阶楼梯的方法之和 class Solution {public: /** * @param n: An integer * @return: An integer */ int climbSta 阅读全文
posted @ 2017-11-05 23:08 叶尘 阅读(104) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param grid: a list of lists of integers * @return: An integer, minimizes the sum of all numbers along its path */ int mi 阅读全文
posted @ 2017-11-05 23:04 叶尘 阅读(101) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param triangle: a list of lists of integers * @return: An integer, minimum path sum */ int minimumTotal(vector<vector<in 阅读全文
posted @ 2017-11-05 23:02 叶尘 阅读(104) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param : a string to be split * @return: all possible split string array */ vector<vector<string>> splitString(string& s) 阅读全文
posted @ 2017-11-05 23:00 叶尘 阅读(116) 评论(0) 推荐(0)
 
摘要: 因只有一个元素只出现一次,其他元素均是两次。所以排序后,对相邻两元素不重复的进行比较,如果有不相等的,则相邻两元素中的前一个元素为落单的数。 class Solution {public: /* * @param A: An integer array * @return: An integer * 阅读全文
posted @ 2017-11-05 22:56 叶尘 阅读(159) 评论(0) 推荐(0)
 
摘要: 因主元素出现次数严格大于所有元素出现次数的一半,故排序后中间元素必是主元素 class Solution {public: /* * @param nums: a list of integers * @return: find a majority number */ int majorityNu 阅读全文
posted @ 2017-11-05 22:50 叶尘 阅读(262) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param nums: a list of integers * @return: A integer indicate the sum of minimum subarray */ int minSubArray(vector<int> 阅读全文
posted @ 2017-11-05 22:46 叶尘 阅读(112) 评论(0) 推荐(0)
 
摘要: class Solution {public: /* * @param nums: A list of integers * @return: A integer indicate the sum of max subarray */ int maxSubArray(vector<int> &num 阅读全文
posted @ 2017-11-05 22:42 叶尘 阅读(108) 评论(0) 推荐(0)
 
摘要: /** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left 阅读全文
posted @ 2017-11-05 22:34 叶尘 阅读(120) 评论(0) 推荐(0)
 
摘要: 分别递归遍历左右子树,并且做比较,选取深度大的一支 /** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this 阅读全文
posted @ 2017-11-05 22:30 叶尘 阅读(145) 评论(0) 推荐(0)
 
摘要: 遍历列表中元素,如果是整数则添加到数组中,如果是列表则递归遍历该列表。 /** * // This is the interface that allows for creating nested lists. * // You should not implement it, or specula 阅读全文
posted @ 2017-11-05 21:53 叶尘 阅读(215) 评论(0) 推荐(0)