摘要: 98验证二叉搜索树 开始想的是递归验证 root.right.val>root.val&&root.left.val<root.val;但是会出现以下情况 二叉搜索树的中序遍历是有序数组是解决二叉搜索树问题的关键。 点击查看代码 class Solution { TreeNode max; publ 阅读全文
posted @ 2024-03-26 23:52 taolll 阅读(9) 评论(0) 推荐(0)
摘要: 前序中序,后序中序确定一颗二叉树。 后序中序确定的思路: 从postorder中取出最后一个数 以这个数为分界点分割中序数组 再根据中序的分组分割后序数组 点击查看代码 class Solution { Map<Integer,Integer> map = new HashMap<>(); publ 阅读全文
posted @ 2024-03-26 00:03 taolll 阅读(7) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/path-sum-ii 点击查看代码 class Solution { public List<List<Integer>> pathSum(TreeNode root, int targetSum) { List<List<Integer> 阅读全文
posted @ 2024-03-24 22:44 taolll 阅读(5) 评论(0) 推荐(0)
点击右上角即可分享
微信分享提示