62.二叉树搜索树的第K个节点——剑指offer
typedef TreeNode* pnode; class Solution { int m; pnode ans; void dfs(pnode p){ if(!p || m < 1) return; dfs(p -> left); if(m == 1) ans = p; --m; if(m > 0) dfs(p -> right); } public: TreeNode* KthNode(TreeNode* p, unsigned int k){ ans = NULL; m = k; dfs(p); return ans; } };