题解 | #按之字形顺序打印二叉树#
二叉搜索树的第k个结点
http://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a
题解:二叉树的中序遍历
public class Solution {
TreeNode res = null;
int count=0;
TreeNode KthNode(TreeNode pRoot, int k) {
if(pRoot==null||k==0) return null;
helper(pRoot,k);
return res;
}
void helper(TreeNode pRoot,int k){
if(pRoot==null) return;
helper(pRoot.left,k);
count++;
if(count==k){
res = pRoot;
}
helper(pRoot.right,k);
}
}