摘要:
题目 本题未成功做出,字符串相关内容不会 1 class Solution { 2 public: 3 void constructpath(TreeNode* root,string path,vector<string>&paths){ 4 if(root!=NULL){ 5 path = pa 阅读全文
posted @ 2021-01-04 17:02
Uitachi
阅读(49)
评论(0)
推荐(0)
摘要:
题目 1 class Solution { 2 public: 3 TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { 4 if((p->val - root->val) * (q->val - roo 阅读全文
posted @ 2021-01-04 16:39
Uitachi
阅读(76)
评论(0)
推荐(0)
摘要:
题目 分析 翻转每个节点左右子树即可。 代码 前序遍历,递归法 1 class Solution { 2 public: 3 TreeNode* invertTree(TreeNode* root) { 4 if(root == NULL) return root; 5 TreeNode* node 阅读全文
posted @ 2021-01-04 15:39
Uitachi
阅读(57)
评论(0)
推荐(0)
摘要:
题目 分析 深搜(一)精简 class Solution { public: bool hasPathSum(TreeNode* root, int sum) { if(root == NULL) return false; if(root->left == NULL && root->right 阅读全文
posted @ 2021-01-04 15:23
Uitachi
阅读(77)
评论(0)
推荐(0)
摘要:
题目 深度优先搜索 1 class Solution { 2 public: 3 int minDepth(TreeNode* root) { 4 if(root == NULL) return 0; 5 if(root->left == NULL) return minDepth(root->ri 阅读全文
posted @ 2021-01-04 11:19
Uitachi
阅读(101)
评论(0)
推荐(0)

浙公网安备 33010602011771号