标签:bool tree node boolean min == false logs etc tree
This answer is so awesome!!
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { Integer min = null; public boolean isValidBST(TreeNode root) { if (root == null) { return true; } if (isValidBST(root.left) && (min == null || min < root.val)) { min = root.val; return isValidBST(root.right); } return false; } }
LeetCode 98: Valid Binary Search Tree
标签:bool tree node boolean min == false logs etc tree
原文地址:http://www.cnblogs.com/shuashuashua/p/7404441.html