摘要:
✅做题思路or感想: 直接递归到叶子节点,然后更新最小值就好了 这不是和上一题一模一样吗 class Solution { public: int result = 99999; void dfs(TreeNode* root, int sum) { if (root->left == nullpt 阅读全文
posted @ 2022-03-27 10:33
北原春希
阅读(33)
评论(0)
推荐(0)
摘要:
✅做题思路or感想: 直接递归到叶子节点,然后更新最大值就好了 class Solution { public: int result = 1; void dfs(TreeNode* cur, int sum) { if (cur->left == nullptr && cur->right == 阅读全文
posted @ 2022-03-27 10:24
北原春希
阅读(29)
评论(0)
推荐(0)
摘要:
✅做题思路or感想: 这题是要同时遍历左子树和右子树 遍历左子树的外侧和右子树的外侧 遍历左子树的内侧和右子树的内侧 最后判读是否外侧和内侧都是对称的 class Solution { public: bool dfs(TreeNode* left, TreeNode* right) { //处理左 阅读全文
posted @ 2022-03-27 10:15
北原春希
阅读(28)
评论(0)
推荐(0)
摘要:
做题思路or感想: 遍历一遍二叉树,然后将遍历节点的左右节点互换就好了 class Solution { public: void dfs(TreeNode* root) { if (root == nullptr)return; swap(root->left, root->right); //交 阅读全文
posted @ 2022-03-27 09:59
北原春希
阅读(39)
评论(0)
推荐(0)

浙公网安备 33010602011771号