leetcode题解-700-二叉搜索树中的搜索 发表于 2019-12-16 | 更新于 2019-12-19 题目 My way 递归 1234567891011121314151617181920212223/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: TreeNode* searchBST(TreeNode* root, int val) { while (root) { if (root->val == val) return root; if (root->val > val) root = root->left; else root = root->right; } return root; }}; 很简单的题目,就不写非递归实现了