class Solution {
public:
TreeNode* res=NULL;
void mid(TreeNode* root, int k,int &cnt)
{
if(!root)
return;
mid(root->left,k,cnt);
cnt++;
if(cnt==k) res=root;
mid(root->right,k,cnt);
}
TreeNode* kthNode(TreeNode* root, int k) {
int cnt=0;
mid(root,k,cnt);
return res;
}
};
标签:结点,TreeNode,int,mid,cnt,二叉,搜索,res,root
From: https://www.cnblogs.com/tangxibomb/p/17379582.html