Snippets Collections
class Solution{

    int searchBST(Node* root, int target, int ans = -1){
            return ans;
        if(root->data <= target){
            ans = root->data;
            return searchBST(root->right,target, ans);
        return searchBST(root->left, target, ans);
    int floor(Node* root, int x) {
        // Code here
        if(!root )  return -1;
        return searchBST(root, x);

Fri Oct 13 2023 03:51:39 GMT+0000 (Coordinated Universal Time)

#bst #binarysearchtree #floor

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension