摘要: ``` class Solution { public: int jump2(vector& nums) { int res = 0, n = nums.size(), last = 0, cur = 0; for (int i = 0; i = n - 1) break; } } return res... 阅读全文
posted @ 2019-04-09 10:02 JohnRed 阅读(70) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: bool isMatch(string s, string p) { int m = s.size(), n = p.size(); vector dp(m + 1, vector(n + 1, false)); dp[0][0] = tru 阅读全文
posted @ 2019-04-09 10:01 JohnRed 阅读(71) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: string multiply(string num1, string num2) { int n1 = num1.size(), n2 = num2.size(); vector tmpres(n1+n2, 0); int k = n1 + n2 - 2; for(i... 阅读全文
posted @ 2019-04-09 09:59 JohnRed 阅读(73) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int trap(vector& height) { int l = 0, r = height.size() 1, level = 0, res = 0; while (l 阅读全文
posted @ 2019-04-09 09:57 JohnRed 阅读(89) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int firstMissingPositive(vector& nums) { int n = nums.size(); for (int i = 0; i 0 && nums[i] 阅读全文
posted @ 2019-04-09 09:55 JohnRed 阅读(78) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector combinationSum2(vector &num, int target) { vector result; vector subsets; vector empty; subsets.push_back(empty); 阅读全文
posted @ 2019-04-09 09:52 JohnRed 阅读(73) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector combinationSum(vector& candidates, int target) { vector res; combinationSumDFS(candidates, target, 0, {}, res); re 阅读全文
posted @ 2019-04-09 09:49 JohnRed 阅读(96) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: string countAndSay(int n) { if (n 阅读全文
posted @ 2019-04-09 09:48 JohnRed 阅读(85) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: void solveSudoku(vector &board) { if (board.empty() || board.size() != 9 || board[0].size() != 9) return; solveSudokuDFS( 阅读全文
posted @ 2019-04-09 09:40 JohnRed 阅读(77) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: bool isValidSudoku(vector &board) { if (board.empty() || board[0].empty()) return false; int m = board.size(), n = board[ 阅读全文
posted @ 2019-04-09 09:38 JohnRed 阅读(69) 评论(0) 推荐(0) 编辑