题解 | #二叉搜索树的第k个结点# 减法求解
二叉搜索树的第k个结点
http://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a
public class Solution { private TreeNode res; private int idx; TreeNode KthNode(TreeNode pRoot, int k) { idx=k; dfs(pRoot); return res; } private void dfs(TreeNode node){ if(node==null) return; dfs(node.left); if(idx==0) return; if(--idx==0) res = node; dfs(node.right); } }