private ArrayList<TreeNode> nodes=null; //思路:中序遍历 TreeNode KthNode(TreeNode pRoot, int k) { if(pRoot==null||k<=0){ return null; } nodes=new ArrayList<TreeNode>(); mid(pRoot); if(k>nodes.size()){ return null; } return nodes.get(k-1); } private void mid(TreeNode root){ if(root==null){ return; } mid(root.left); nodes.add(root); mid(root.right); }