LeetCode 98.验证二叉搜索树
/*
* 思路:验证二叉搜索树,即验证中序遍历序列是否是一个升序数组
*
*/
struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;
TreeNode() : val(0), left(nullptr), right(nullptr) {}
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};
class Solution {
public:
vector
void inorder(TreeNode* root)
{
if (!root)
return;
inorder(root-
共有 0 条评论