Sir, on submitting on hackerrank, 3 testcases are failing.
Check for BST test case
bool helper(Node* root, int minV = INT_MIN, int maxV = INT_MAX) {
if(root==NULL) return true;
if(root->data >= minV && root->data <= maxV && helper(root->left,minV,root->data)&& helper(root->right,root->data,maxV)) {
return true;
}
return false;
}
bool checkBST(Node* root) {
return helper(root,INT_MIN,INT_MAX);
}
hi @anishanand3733 i think they want to check stictly greater than or strictly less than, so change this line to root->data > minV && root->data < maxV
I am unable to submit and check because it is giving error for INT_MIN and INT_MAX, is there a way to include header files in this?
Thanks, successfully submitted.
Yes we have to explicitly include header file above the functions.
1 Like