![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
leo524891010
坚持 耐心 高效
展开
-
[Leetcode] Symmetric Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-02 00:49:16 · 365 阅读 · 0 评论 -
[Leetcode] Climbing Stairs
class Solution {public: int climbStairs(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if (n == 1) return 1; el原创 2012-12-02 02:22:19 · 363 阅读 · 0 评论 -
[Leetcode] Binary Tree Inorder Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-02 03:43:49 · 338 阅读 · 0 评论 -
[Leetcode] Binary Tree Level Order Traversal II
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-02 08:50:20 · 333 阅读 · 0 评论 -
[Leetcode] Convert Sorted Array to Binary Search Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 03:32:26 · 410 阅读 · 0 评论 -
[Leetcode] Palindrome Number
class Solution {public: bool isPalindrome(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function if (x == 0) return true;原创 2012-12-03 08:48:35 · 596 阅读 · 0 评论 -
[Leetcode] First Missing Positive
class Solution {public: int firstMissingPositive(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if (n < 0) ret原创 2012-12-03 10:10:22 · 465 阅读 · 0 评论 -
[Leetcode] Best Time to Buy and Sell Stock
class Solution {public: int maxProfit(vector &a) { // Start typing your C/C++ solution below // DO NOT write int main() function int minIdx = 0; int diff = 0;原创 2012-12-01 09:26:25 · 514 阅读 · 0 评论 -
[Leetcode] Best Time to Buy and Sell Stock II
class Solution {public: int maxProfit(vector &a) { // Start typing your C/C++ solution below // DO NOT write int main() function int prevIdx = 0; int res原创 2012-12-01 09:58:46 · 720 阅读 · 0 评论 -
[Leetcode] Combination Sum II
class Solution {public: vector > combinationSum2(vector &candidates, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > r原创 2012-12-02 13:56:02 · 412 阅读 · 0 评论 -
[Leetcode] Combinations
class Solution {public: vector > combine(int n, int k) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > res; vector cache;原创 2012-12-02 14:21:48 · 651 阅读 · 0 评论 -
[Leetcode] Same Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 04:54:46 · 382 阅读 · 0 评论 -
[Leetcode] Valid Parentheses
class Solution {public: bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function stack buf; for (int i = 0; i < s.siz原创 2012-12-03 05:07:53 · 449 阅读 · 0 评论 -
[Leetcode] Maximum Subarray
class Solution {public: int maxSubArray(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function bool isAllNeg = true;原创 2012-12-03 07:22:22 · 583 阅读 · 0 评论 -
[Leetcode] Minimum Depth of Binary Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 08:07:17 · 507 阅读 · 0 评论 -
[Leetcode] Two Sum
class Solution {public: struct pair { int data; int idx; bool operator< (const pair& rhs) const { return data < rhs.data; } }; vec原创 2012-12-02 01:56:39 · 498 阅读 · 0 评论 -
[Leetcode] Best Time to Buy and Sell Stock III
class Solution {public: int maxProfit(vector &prices) { // Start typing your C/C++ solution below // DO NOT write int main() function if (a.size() == 0)原创 2012-12-01 12:04:01 · 671 阅读 · 0 评论 -
[Leetcode] Construct Binary Tree from Preorder and Inorder Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 03:14:12 · 576 阅读 · 0 评论 -
[Leetcode] Convert Sorted List to Binary Search Tree
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *//** * Definition for binary tree * stru原创 2012-12-03 04:07:35 · 368 阅读 · 0 评论 -
[Leetcode] Validate Binary Search Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 05:12:17 · 515 阅读 · 0 评论 -
[Leetcode] Maximum Depth of Binary Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 08:17:48 · 367 阅读 · 0 评论 -
[Leetcode] Add Binary
class Solution {public: string addBinary(string a, string b) { // Start typing your C/C++ solution below // DO NOT write int main() function string res; a.size() >原创 2012-12-02 02:59:26 · 360 阅读 · 0 评论 -
[Leetcode] 3Sum Closest
class Solution {public: int threeSumClosest(vector &num, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function sort(num.begin(), num.原创 2012-12-01 13:56:04 · 544 阅读 · 0 评论 -
[Leetcode] Binary Tree Level Order Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-02 08:11:25 · 401 阅读 · 0 评论 -
[Leetcode] Binary Tree Zigzag Level Order Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-02 11:39:19 · 436 阅读 · 0 评论 -
[Leetcode] Combination Sum
class Solution {public: vector > combinationSum(vector &candidates, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > re原创 2012-12-02 13:27:51 · 415 阅读 · 0 评论 -
[Leetcode] Search a 2D Matrix
class Solution {public: bool searchMatrix(vector > &matrix, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function int i = 0;原创 2012-12-03 04:25:52 · 486 阅读 · 0 评论 -
[Leetcode] Path Sum II
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2012-12-03 09:10:22 · 461 阅读 · 0 评论 -
[Leetcode] Jump Game II
//大数据集 超时动态规划做法class Solution {public: int jump(int a[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if (!n) return 0;原创 2012-12-04 03:46:54 · 474 阅读 · 0 评论 -
[Leetcode] Gray Code
class Solution {public: vector grayCode(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function vector res; int total = 1 << n;原创 2012-12-04 08:14:00 · 483 阅读 · 0 评论 -
[Leetcode] Edit Distance
class Solution {public: int minDistance(string word1, string word2) { // Start typing your C/C++ solution below // DO NOT write int main() function int res = 0;原创 2012-12-03 23:58:43 · 625 阅读 · 0 评论 -
[Leetcode] Count and Say
class Solution {public: string countAndSay(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function string s = "1"; for (int原创 2012-12-03 12:12:50 · 694 阅读 · 0 评论 -
[Leetcode] Distinct Subsequences *
class Solution {public: int numDistinct(string S, string T) { // Start typing your C/C++ solution below // DO NOT write int main() function int res = 0; match(S, T原创 2012-12-03 13:48:35 · 601 阅读 · 0 评论 -
[Leetcode] Length of Last Word
class Solution {public: int lengthOfLastWord(const char *s) { // Start typing your C/C++ solution below // DO NOT write int main() function int length = strlen(s);原创 2012-12-04 03:56:42 · 472 阅读 · 0 评论 -
[LeetCode] Divide Two Integers
class Solution {public: int divide(int dividend, int divisor) { // Start typing your C/C++ solution below // DO NOT write int main() function long long a = dividend;原创 2012-12-03 23:40:27 · 623 阅读 · 0 评论 -
[Leetcode] Generate Parentheses
class Solution {public: vector generateParenthesis(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function vector res; string s = ""原创 2012-12-04 04:05:41 · 545 阅读 · 0 评论 -
[Leetcode] Word Search
class Solution {public: bool exist(vector > &board, string word) { // Start typing your C/C++ solution below // DO NOT write int main() function vector used;原创 2012-12-04 09:49:20 · 743 阅读 · 0 评论 -
[Leetcode] Pascal's Triangle
class Solution {public: vector > generate(int numRows) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > res;原创 2012-12-04 14:04:19 · 664 阅读 · 0 评论 -
[Leetcode] Largest Rectangle in Histogram
class Solution {public: int largestRectangleArea(vector &height) { // Start typing your C/C++ solution below // DO NOT write int main() function int q[100000] = {-1};原创 2012-12-04 23:49:43 · 504 阅读 · 0 评论 -
[Leetcode] Letter Combinations of a Phone Number
class Solution {private: map > dict;public: vector letterCombinations(string digits) { // Start typing your C/C++ solution below // DO NOT write int main() function原创 2012-12-05 03:52:49 · 559 阅读 · 0 评论