上一页 1 2 3 4 5 6 7 ··· 17 下一页
摘要: class Solution { public: int countBattleships(vector>& board) { int res = 0; for (int i = 0; i 0 && board[i-1][j] == 'X' || j > 0 && board[i][j-1] == 'X') ... 阅读全文
posted @ 2018-11-27 17:03 JTechRoad 阅读(73) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int kthGrammar(int N, int K) { return helper(N, K, false); } int helper(int n, int k, bool reverse) { if (n == 1) return reverse; int tota... 阅读全文
posted @ 2018-11-27 05:42 JTechRoad 阅读(97) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
posted @ 2018-11-27 05:33 JTechRoad 阅读(91) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector fizzBuzz(int n) { vector res; for (int i = 1; i <= n; i++) { if (i % 3 == 0 && i % 5 == 0) res.push_back("FizzBuzz"); ... 阅读全文
posted @ 2018-11-24 16:53 JTechRoad 阅读(107) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
posted @ 2018-11-24 16:40 JTechRoad 阅读(52) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int majorityElement(vector& nums) { int m = 0, c = 0; for (auto i : nums) { if (c == 0) { m = i; c++; ... 阅读全文
posted @ 2018-11-24 16:36 JTechRoad 阅读(76) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* d... 阅读全文
posted @ 2018-11-24 15:44 JTechRoad 阅读(55) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int maximalRectangle(vector>& matrix) { int m = matrix.size(); if (m == 0) return 0; int n = matrix[0].size(); if (n == 0) return 0; vector> v(m,... 阅读全文
posted @ 2018-11-24 15:27 JTechRoad 阅读(85) 评论(0) 推荐(0) 编辑
摘要: // Forward declaration of isBadVersion API. bool isBadVersion(int version); class Solution { public: int firstBadVersion(int n) { int i = 1, j = n; while (i< j - 1) { ... 阅读全文
posted @ 2018-11-24 13:57 JTechRoad 阅读(81) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool PredictTheWinner(vector& nums) { return helper(nums, 0, nums.size()-1, true, 0, 0); } // return true if player1 can win. false if player1 will lose. ... 阅读全文
posted @ 2018-11-23 16:35 JTechRoad 阅读(120) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 17 下一页