Advertisement
knakul853

Untitled

Jul 24th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. /**
  2.     knakul853
  3.  */
  4. class Solution {
  5. public:
  6.     bool isValidBST(TreeNode* root, long mn=LONG_MIN, long mx=LONG_MAX ) {
  7.         if( !root ) return true;
  8.          
  9.          if( root->val <= mn || root->val >= mx) return 0;
  10.        
  11.         return isValidBST(root->left, mn, root->val ) && isValidBST(root->right, root->val, mx);
  12.        
  13.     }
  14.    
  15. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement