摘要:
``` 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
阅读(95)
评论(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
阅读(77)
评论(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
阅读(90)
评论(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
阅读(91)
评论(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
阅读(99)
评论(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
阅读(117)
评论(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
阅读(114)
评论(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
阅读(76)
评论(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
阅读(94)
评论(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
阅读(76)
评论(0)
推荐(0)

浙公网安备 33010602011771号