摘要:
看了别人的代码 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * Tre... 阅读全文
摘要:
一次过。。 1 class Solution { 2 public: 3 bool isValidSudoku(vector > &board) { 4 // Start typing your C/C++ solution below 5 // DO NOT... 阅读全文
摘要:
一次过 1 class Solution { 2 public: 3 bool isValid(string s) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main... 阅读全文
摘要:
基本一次过吧,题目没说数字要算进去啊。。 1 class Solution { 2 public: 3 bool check(string t) { 4 for (int i = 0; i < t.size(); i++) { 5 if (t[i] != t[t.size()-1-i]) return false; 6 } 7 return true; 8 } 9 bool isPalindrome(string s) {10 // Start typing your C/C++ s... 阅读全文
摘要:
leetcode里最恶心的题目。。面试问这种题目可以去撞墙了。。自己写了一遍 1 class Solution { 2 public: 3 bool isNumber(const char *s) { 4 // Start typing your C/C++ solution... 阅读全文
摘要:
一次过了 1 class Solution { 2 public: 3 int uniquePathsWithObstacles(vector > &obstacleGrid) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文
摘要:
一次过 1 class Solution { 2 public: 3 int uniquePaths(int m, int n) { 4 // Start typing your C/C++ solution below 5 // DO NOT write i... 阅读全文
摘要:
贴下自己写的不用指针的代码,更加容易懂吧 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right;... 阅读全文
摘要:
有经验了,一上来就知道用dp, 一次过 1 class Solution { 2 public: 3 int numTrees(int n) { 4 // Start typing your C/C++ solution below 5 // DO NOT w... 阅读全文
摘要:
坑爹的多数次过。。 1 class Solution { 2 public: 3 vector twoSum(vector &numbers, int target) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文
摘要:
基本一次过 1 class Solution { 2 public: 3 int minimumTotal(vector<vector<int> > &triangle) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if (!triangle.size()) return 0; 7 if (triangle.size() == 1) return triangle[0][0]; 8 ... 阅读全文
摘要:
继续不争气看网上答案。。 1 class Solution { 2 public: 3 int trap(int A[], int n) { 4 // Start typing your C/C++ solution below 5 // DO NOT wri... 阅读全文
摘要:
越到后面越不给力了,这题又看了答案。。 1 class Solution { 2 public: 3 vector fullJustify(vector &words, int L) { 4 vector ans; 5 int cur = 0; 6 ... 阅读全文
摘要:
看了网上答案 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * Tree... 阅读全文
摘要:
一次过 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x),... 阅读全文
摘要:
看了网上答案,dfs 1 class Solution { 2 public: 3 void dfs(vector> &board, int x, int y) { 4 if (x = board.size() || y = board.size()) return; 5 ... 阅读全文