leetcode 0405 檢查二叉搜尋樹 阿新 • • 發佈:2021-01-03 技術標籤:leetcodeleetcodejava Integer res = null; boolean flag =true; public boolean isValidBST(TreeNode root) { if (root == null) return true; isValidBST(root.left); if (res == null) res = root.val; else if (root.val <= res) flag = false; else { res = root.val; } isValidBST(root.right); return flag; }