[Leetcode]Validate Binary Search Tree
来源:互联网 发布:网络优化方案 编辑:程序博客网 时间:2024/04/29 13:18
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: bool isValidBST(TreeNode *root) { // Start typing your C/C++ solution below // DO NOT write int main() function return isValidBST(root, INT_MIN, INT_MAX); } bool isValidBST(TreeNode *root, int min, int max) { if(root == NULL) return true; if(root->val > max || root->val < min) return false; return isValidBST(root->left, min, root->val-1) && isValidBST(root->right, root->val+1, max); }};
- LeetCode: Validate Binary Search Tree
- [Leetcode] Validate Binary Search Tree
- LeetCode : Validate Binary Search Tree
- [LeetCode] Validate Binary Search Tree
- [LeetCode] Validate binary search tree
- [LeetCode]Validate Binary Search Tree
- [Leetcode]Validate Binary Search Tree
- [leetcode]Validate Binary Search Tree
- LeetCode-Validate Binary Search Tree
- [leetcode] Validate Binary Search Tree
- LeetCode - Validate Binary Search Tree
- [LeetCode] Validate Binary Search Tree
- Leetcode Validate Binary Search Tree
- LeetCode | Validate Binary Search Tree
- LeetCode - Validate Binary Search Tree
- Leetcode: Validate Binary Search Tree
- 【Leetcode】Validate Binary Search Tree
- 【leetcode】Validate Binary Search Tree
- Myeclipser下servlet的使用
- 第四章 例4.11
- 配置Eclipse的Hadoop插件时无法连接HDFS的解决办法
- Hadoop 在Linux 单机上伪分布式 的安装过程
- 使用 CXF 做 webservice 简单例子
- [Leetcode]Validate Binary Search Tree
- Spring MVC 教程,快速入门,深入分析
- Hadoop入门——《Hadoop实战初级部分》学习笔记
- 工作两年,反省与总结
- 程序员的四种类型
- jQuery插件之-瀑布流插件
- stl lower_bound 和 upper_bound
- 执子之手
- Qt国际化相关类