public class Solution { public boolean isValidBST(TreeNode root) { Stack<TreeNode> stack=new Stack<TreeNode>(); TreeNode cur=null; while(root!=null||!stack.isEmpty()) { while(root!=null) { stack.push(root); root=root.left; } root=stack.pop(); if(cur!=null&&cur.val>=root.val) return false; cur=root; root=root.right; } return true; } }
98. Validate Binary Search Tree
原文:http://www.cnblogs.com/asuran/p/7609352.html