题解 | #把字符串转换成整数#Java递归
二叉搜索树的第k个结点
http://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a
/* public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } */ public class Solution { int num = 0; int k; TreeNode ans; TreeNode KthNode(TreeNode pRoot, int k) { if(pRoot == null){ return null; } this.k = k; helper(pRoot); return ans; } void helper(TreeNode pRoot){ if(pRoot == null){ return; } if(pRoot.left != null){ helper(pRoot.left); } num++; if(num == k){ ans = pRoot; return; } if(pRoot.right != null){ helper(pRoot.right); } } }