摘要:
题目 1 class Solution { 2 public: 3 bool isBalanced(TreeNode* root) { 4 if(root == NULL) return true; 5 return abs(height(root->left)-height(root->right 阅读全文
posted @ 2021-01-02 17:41
Uitachi
阅读(82)
评论(0)
推荐(0)
摘要:
题目 1 class Solution { 2 public: 3 TreeNode* sortedArrayToBST(vector<int>& nums) { 4 if(nums.size() == 0) return NULL; 5 return build_BST(nums,0,nums.s 阅读全文
posted @ 2021-01-02 17:18
Uitachi
阅读(67)
评论(0)
推荐(0)
摘要:
题目 1 class Solution { 2 public: 3 vector<vector<int>> levelOrderBottom(TreeNode* root) { 4 auto levelOrder = vector<vector<int>> (); 5 if(root == NULL 阅读全文
posted @ 2021-01-02 16:34
Uitachi
阅读(68)
评论(0)
推荐(0)
摘要:
题目 1 class Solution { 2 public: 3 int maxDepth(TreeNode* root) { 4 if(root == NULL) return 0; 5 //return maxDepth(root->left) > maxDepth(root->right) 阅读全文
posted @ 2021-01-02 15:49
Uitachi
阅读(67)
评论(0)
推荐(0)
摘要:
题目 1 class Solution { 2 public: 3 4 bool isSymmetric(TreeNode* root) { 5 return check(root,root); 6 } 7 bool check(TreeNode* p,TreeNode* q) { 8 if(!p 阅读全文
posted @ 2021-01-02 15:05
Uitachi
阅读(75)
评论(0)
推荐(0)
摘要:
题目 1 class Solution { 2 public: 3 bool isSameTree(TreeNode* p, TreeNode* q) { 4 if(p == NULL && q == NULL){ 5 return true; 6 }else if(p == NULL || q = 阅读全文
posted @ 2021-01-02 11:05
Uitachi
阅读(69)
评论(0)
推荐(0)
摘要:
题目描述 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode() : val(0), 阅读全文
posted @ 2021-01-02 10:16
Uitachi
阅读(83)
评论(0)
推荐(0)

浙公网安备 33010602011771号