代码

public class Solution {
List<Integer> list = new ArrayList<Integer>();

public boolean isValidBST(TreeNode root) {
//二叉查找数 如果中序遍历结果是一个递增的排序序列
if (root == null) return true;
if (root.left == null && root.right == null) return true;
inOrderTraversal(root);//中序遍历
for (int i = 1; i < list.size(); i++) {
if (list.get(i) <= list.get(i - 1)) return false;
}
return true;
}

public void inOrderTraversal(TreeNode root){
if (root == null) return;
inOrderTraversal(root.left);
inOrderTraversal(root.right);
}
}

【LeetCode】Validate Binary Search Tree 解题报告

2014-12-03 16:58:25

LeetCode 98 — Validate Binary Search Tree（C++ Java Python）

2014-04-02 09:51:35

leetcode 98 Validate Binary Search Tree (python)

2016-07-27 08:36:02

LeetCode(98)Validate Binary Search Tree

2014-01-17 10:15:46

98. Validate Binary Search Tree--非递归的方法可以想下

2017-01-18 13:33:39

[leetcode-98]Validate Binary Search Tree（c++)

2015-08-10 22:19:26

Validate Binary Search Tree -- LeetCode

2014-04-16 04:34:52

[C++]LeetCode: 122 Validate Binary Search Tree (是否是合法BST树)

2015-01-25 17:01:28

二叉查找树（binary search tree）——python实现

2014-07-11 21:59:32

[Leetcode] 98. Validate Binary Search Tree @python

2016-01-24 13:49:55

不良信息举报

98. Validate Binary Search Tree