二叉搜索树的验证算法Binary Search Tree 发表于 2022-05-20 更新于 2025-02-20 分类于 算法 学习笔记 验证二叉搜索树的条件 二叉树(Binary Tree) 空树(Empty) root > left && root < right 算法1234567public boolean checkBST(TreeNode root, int min, int max) { if (root == null) return false; if (root.val < min || root.val > max) return false; return checkBST(root.left, min, root.val) && checkBST(root.right, root.val, max);} 时间复杂度 O(n)