//剑指offer54 //二叉搜索树 通过中序遍历所得到的序列就是有序的 而且是从小到大排序的 public int kthLargest(TreeNode root, int k) { ArrayList<Integer> list = new ArrayList<>(); treeloop(root,list); return list.get(list.size()-k); } public void treeloop(TreeNode root,ArrayList list){ if(root == null) return ; treeloop(root.left,list); list.add(root.val); treeloop(root.right,list); }
04-27
190
10-22
3709
10-28
325