Validate Binary Search Tree
来源:互联网 发布:淘宝网店交易 编辑:程序博客网 时间:2024/05/15 13:04
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution { // 中序遍历public: Solution(){ prev = NULL; } bool isValidBST(TreeNode* root) { if (!root) return true; if (!isValidBST(root->left)) return false; if (prev && root->val <= prev->val) return false; prev = root; if (!isValidBST(root->right)) return false; return true; }private: TreeNode* prev;};
0 0
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- Validate Binary Search Tree
- OkHttp源码分析
- 如何用Emacs编译C++代码
- JavaMail API 概述
- POJ 1990 MooFest
- 史上最全的程序猿面试资料
- Validate Binary Search Tree
- Spring面试题
- 模板方法内返回默认值问题
- AngularJS变量无法显示
- 生活中的英语(二)
- UVA11270 Tiling Dominoes 轮廓线|插头 DP入门
- English Daily - August 6,2016-Letty
- 工厂模式
- 推荐的几本数学书【by DaHua Lin】