https://leetcode.com/problems/validate-binary-search-tree/

class Solution {
  bool isValidBSTUtil(TreeNode *root, long l, long r) {
    if (!root) {
      return true;
    }

    if (root->val <= l || root->val >= r) {
      return false;
    }

    return isValidBSTUtil(root->left, l, root->val) &&
           isValidBSTUtil(root->right, root->val, r);
  }

public:
  bool isValidBST(TreeNode *root) {
    return isValidBSTUtil(root, LONG_MIN, LONG_MAX);
  }
};