Validate Binary Search Tree Posted on 2018-10-22 Descriptionhttps://leetcode.com/problems/validate-binary-search-tree/ Solution123456789101112131415161718192021222324252627/** * 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: bool isValidBST(TreeNode* root) { return helper(LONG_MIN, LONG_MAX, root); } bool helper(long lowerBound, long upperBound, TreeNode* root) { if (root == NULL) return true; if (root->val <= lowerBound || root->val >= upperBound) { return false; } return helper(lowerBound, root->val, root->left) && helper(root->val, upperBound, root->right); } };