C++ || Recursive || Easy code
Here is my c++ code for this problem.\n\'\'\'\n/\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode left;\n *     Tr
Here is my c++ code for this problem.\n\'\'\'\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\n \nclass Solution {\npublic:\n\n    TreeNode* searchBST(TreeNode* root, int val) {\n        while(root && root->val!=val){\n            root=root->val>val?root->left:root->right;\n        }\n        return root;\n    }\n};\n\'\'\'
['Binary Search Tree', 'Recursion', 'C']