Untitled
unknown
c_cpp
3 years ago
339 B
7
Indexable
int floorInBST(TreeNode<int> * root, int X)
{
if (root == NULL)
return -1;
if (root -> val == X)
return root -> val;
else if (X < root -> val)
return floorInBST(root -> left, X);
else {
int val;
return (val = floorInBST(root->right, X)) != -1 ? val : root->val;
}
}Editor is loading...