上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 32 下一页
摘要: ``` class Solution { public: bool canJump(vector& nums) { vector dp(nums.size(), 0); for (int i = 1; i & nums) { int n = nums.size(), reach = 0; for (int i = 0; i ... 阅读全文
posted @ 2019-04-09 10:22 JohnRed 阅读(90) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector spiralOrder(vector > &matrix) { if (matrix.empty() || matrix[0].empty()) return {}; int m = matrix.size(), n = matrix[0].size(); vector ... 阅读全文
posted @ 2019-04-09 10:21 JohnRed 阅读(70) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int maxSubArray(vector& nums) { int res = INT_MIN, curSum = 0; for (int num : nums) { curSum = max(curSum + num, num); res = ma... 阅读全文
posted @ 2019-04-09 10:19 JohnRed 阅读(85) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int totalNQueens(int n) { int res = 0; vector pos(n, 1); totalNQueensDFS(pos, 0, res); return res; } void totalNQueensDFS 阅读全文
posted @ 2019-04-09 10:18 JohnRed 阅读(82) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector solveNQueens(int n) { vector res; vector pos(n, 1); solveNQueensDFS(pos, 0, res); return res; } void solveNQueensD 阅读全文
posted @ 2019-04-09 10:16 JohnRed 阅读(93) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: double myPow(double x, int n) { double res = 1.0; for (int i = n; i != 0; i /= 2) { if (i % 2 != 0) res = x; x = x; } ret 阅读全文
posted @ 2019-04-09 10:15 JohnRed 阅读(106) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector anagrams(vector &strs) { string s; map anagram; vector res; for (int i = 0; i = 0) { res.push_back(strs[anag... 阅读全文
posted @ 2019-04-09 10:11 JohnRed 阅读(106) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: void rotate(vector &matrix) { int n = matrix.size(); for (int i = 0; i 阅读全文
posted @ 2019-04-09 10:10 JohnRed 阅读(69) 评论(0) 推荐(0) 编辑
摘要: ```class Solution { public: vector> permuteUnique(vector& nums) { vector> res; vector out, visited(nums.size(), 0); sort(nums.begin(), nums.end()); permuteUniqueDFS... 阅读全文
posted @ 2019-04-09 10:05 JohnRed 阅读(88) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector permute(vector& num) { vector res; vector out, visited(num.size(), 0); permuteDFS(num, 0, visited, out, res); retu 阅读全文
posted @ 2019-04-09 10:04 JohnRed 阅读(69) 评论(0) 推荐(0) 编辑
上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 32 下一页