现给定树的根结点指针TreeNode* root,编辑函数返回一个bool值,判断该树是否为二叉查找树。
加载中...
import java.util.*; /* public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } }*/ public class Checker { public boolean checkBST(TreeNode root) { // write code here } }
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Checker { public: bool checkBST(TreeNode* root) { // write code here } };
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Checker: def checkBST(self, root): # write code here
/* public class TreeNode { public int val; public TreeNode left; public TreeNode right; public TreeNode (int x) { val = x; } }*/ class Checker { public bool checkBST(TreeNode root) { // write code here } }