摘要:
``` class Solution { public: vector getRow(int rowIndex) { vector res(rowIndex + 1); res[0] = 1; for (int i = 1; i = 1; --j) { res[j] += res[j - 1]; ... 阅读全文
posted @ 2019-04-09 15:22
JohnRed
阅读(52)
评论(0)
推荐(0)
摘要:
``` class Solution { public: vector generate(int numRows) { vector res(numRows, vector()); for (int i = 0; i 阅读全文
posted @ 2019-04-09 15:21
JohnRed
阅读(87)
评论(0)
推荐(0)
摘要:
``` class Solution { public: Node* connect(Node* root) { if (!root) return NULL; Node *p = root->next; while (p) { if (p->left) { p = p->left; ... 阅读全文
posted @ 2019-04-09 15:20
JohnRed
阅读(87)
评论(0)
推荐(0)
摘要:
``` class Solution { public: Node* connect(Node* root) { if (!root) return NULL; if (root->left) root->left->next = root->right; if (root->right) root->right->next = root->... 阅读全文
posted @ 2019-04-09 15:18
JohnRed
阅读(69)
评论(0)
推荐(0)
摘要:
``` class Solution { public: int numDistinct(string S, string T) { int dp[T.size() + 1][S.size() + 1]; for (int i = 0; i 阅读全文
posted @ 2019-04-09 15:15
JohnRed
阅读(93)
评论(0)
推荐(0)
摘要:
``` // Recursion class Solution { public: void flatten(TreeNode *root) { if (!root) return; if (root->left) flatten(root->left); if (root->right) flatten(root->right); ... 阅读全文
posted @ 2019-04-09 15:14
JohnRed
阅读(70)
评论(0)
推荐(0)
摘要:
``` class Solution { public: vector > pathSum(TreeNode *root, int sum) { vector> res; vector out; helper(root, sum, out, res); return res; } void helper(Tre... 阅读全文
posted @ 2019-04-09 15:11
JohnRed
阅读(75)
评论(0)
推荐(0)
摘要:
``` class Solution { public: bool hasPathSum(TreeNode* root, int sum) { if (!root) return false; if (!root->left && !root->right && root->val == sum ) return true; return h... 阅读全文
posted @ 2019-04-09 15:10
JohnRed
阅读(84)
评论(0)
推荐(0)
摘要:
``` class Solution { public: int minDepth(TreeNode* root) { if (!root) return 0; if (!root->left) return 1 + minDepth(root->right); if (!root->right) return 1 + minDepth(ro... 阅读全文
posted @ 2019-04-09 15:04
JohnRed
阅读(74)
评论(0)
推荐(0)
摘要:
```
class Solution {
public: bool isBalanced(TreeNode *root) { if (checkDepth(root) == -1) return false; else return true; } int checkDepth(TreeNode *root) { if... 阅读全文
posted @ 2019-04-09 15:03
JohnRed
阅读(105)
评论(0)
推荐(0)

浙公网安备 33010602011771号