try the prateek bhaiya code shoowing error on the limits please chefck
Https://leetcode.com/problems/validate-binary-search-tree
plz share code as well
you should have to use range based approach here
are you using that
or naïve approach
**
- Definition for a binary tree node.
- 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:
 bool isBST(TreeNode root, int min_val,int max_val){
 if(root == NULL) return true;
 if(root->val <max_val and root->val >min_val and isBST(root->left,min_val,root->val) and isBST(root->right,root->val,max_val)) return true;
 return false;
 }
 bool isValidBST(TreeNode* root) {
 bool ans = isBST(root,INT_MIN,INT_MAX);
 return ans;
 }
 };
the approach that was there in the course
Yes approach is correct but you have to do some changes in this
because there may be one case
[2147483647 , 2147483647]
i am sharing my code wait a min
