[C++] | ITERATIVE O(LogN) SOLUTION WITH EXPLAINATION | SC : O(1) |
seaching in BST is similliar as binary search in sorted array. what we do is first we check if root has the target value than we return root \nif root doesn\'t 
seaching in BST is similliar as binary search in sorted array. what we do is first we check if root has the target value than we return root \nif root doesn\'t have target value than \n* we compare root value with target if value is greater than root than our ans root will lie in left subtree because in BST all left child is smaller than root and all right child is greater than root in terms of value stored so we simply asign root to root->left\n* if root value is lesser than target than our answer root will lie in the right subtree because we want larger value than root\'s value which we can get in only right subtree of that root so we simply assign root to root->right.\n\nwe repeat the above process until we get our ans or root is NULL. if answer exist than our loop will return that root otherwise at last we will return nullptr.\n\n\n```\nclass Solution {\npublic:\n    TreeNode* searchBST(TreeNode* root, int val) {\n        \n        while(root!=nullptr){\n            if(root->val == val) return root;\n            else if(root->val > val) root=root->left;\n            else root=root->right;\n        }\n        return nullptr;\n    }\n};\n```
['Binary Search Tree', 'C']