class Solution {
public:
bool isValidBST(TreeNode *root, int lower, int upper)
{
if (root == NULL)
return true;
if (!root>left&&!root>right)
return root>val > lower&&root>val < upper;
return isValidBST(root>left, lower, root>val)&&isValidBST(root>right, root>val, upper);
}
bool isValidBST(TreeNode *root)
{
return isValidBST(root, INT_MIN, INT_MAX);
}
};
Why is my answer wrong for{87,84,94,79,#,#,#,77,#,82,#,70,#,38,#,36,45,22,#,#,#,18,24,14...}


bool isValidBST(TreeNode *root, int lower, int upper) { if (root == NULL) return true; if (!root>left&&!root>right) return root>val > lower&&root>val < upper; // lines below it are never touched return isValidBST(root>left, lower, root>val)&&isValidBST(root>right, root>val, upper); }
UPDATEDABANDON ABOVE
Look into this {5,14,#,1,#} , the tree looks like this:
5 / 14 / 1