摘要:
class Solution { public: unordered_set res; // DFS may produce dup result, use set to filter. vector removeInvalidParentheses(string s) { // Calculate rmL and rmR for the numbers o... 阅读全文
摘要:
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
摘要:
class Solution { public: vector res; vector addOperators(string num, int target) { if (num.length() == 0) return res; helper(num, target, "", 0, 0, 0); return res; ... 阅读全文
摘要:
class Solution { public: int hIndex(vector& citations) { if (citations.size() == 0) return 0; int i = 0, j = citations.size(); while (i citations[pos]) j... 阅读全文
摘要:
class Solution { public: int hIndex(vector& citations) { int n = citations.size(); vector buck(n+1, 0); for (auto c : citations) { if (c > n) c... 阅读全文
摘要:
class Solution { public: vector productExceptSelf(vector& nums) { if (nums.size() == 0) return vector(); vector res(nums.size(), 1); for (int i = 1; i = 0; i--) { ... 阅读全文
摘要:
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
摘要:
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla... 阅读全文
摘要:
Recurision, TLE. DP: 阅读全文
摘要:
class Solution { public: int maximalSquare(vector>& matrix) { int m = matrix.size(); if (m == 0) return 0; int n = matrix[0].size(); if (n == 0) return 0; vector> dp(m+1,... 阅读全文