摘要: 题目 1 class Solution { 2 public: 3 TreeNode* r1;TreeNode* r2; 4 bool isCousins(TreeNode* root, int x, int y) { 5 dfs(root,r1,x); 6 dfs(root,r2,y); 7 in 阅读全文
posted @ 2021-01-13 17:47 Uitachi 阅读(93) 评论(0) 推荐(0)
摘要: 题目 1 class Solution { 2 public: 3 int flag = 0; 4 bool isUnivalTree(TreeNode* root){ 5 isUnivalTree1(root,root->val); 6 if(flag == 0) return true; 7 e 阅读全文
posted @ 2021-01-13 16:32 Uitachi 阅读(65) 评论(0) 推荐(0)
摘要: 题目 1 class Solution { 2 public: 3 int sum = 0; 4 int rangeSumBST(TreeNode* root, int low, int high) { 5 dfs(root,low,high); 6 return sum; 7 } 8 void d 阅读全文
posted @ 2021-01-13 16:13 Uitachi 阅读(82) 评论(0) 推荐(0)
摘要: 题目 法一、自己 1 class Solution { 2 public: 3 vector<int>res; 4 TreeNode* increasingBST(TreeNode* root) { 5 dfs(root); 6 TreeNode* p = new TreeNode(0); 7 Tr 阅读全文
posted @ 2021-01-13 16:08 Uitachi 阅读(80) 评论(0) 推荐(0)
摘要: 题目 1 class Solution { 2 public: 3 vector<int>ans1; 4 vector<int>ans2; 5 bool leafSimilar(TreeNode* root1, TreeNode* root2) { 6 dfs(root1,ans1); 7 dfs( 阅读全文
posted @ 2021-01-13 15:16 Uitachi 阅读(70) 评论(0) 推荐(0)