Advertisement
knakul853

Untitled

Jul 23rd, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. /**
  2.  knakul853
  3.  */
  4. class Solution {
  5. public:
  6.     TreeNode* searchBST(TreeNode* root, int val) {
  7.        
  8.         if(!root)return NULL;
  9.        
  10.         if(root->val == val) return root;
  11.        
  12.         if(root->val < val){
  13.            return  searchBST(root->right, val);
  14.         }
  15.         else{
  16.             return searchBST(root->left, val);
  17.         }
  18.        
  19.        
  20.        
  21.     }
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement