Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- TreeNode* searchBST(TreeNode* root, int val) {
- if(root == nullptr) return nullptr;
- if( root->val == val)
- return root;
- else{
- if(val < root->val) return searchBST(root->left, val);
- else return searchBST(root->right, val);
- }
- return NULL;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement