-
3.27
- …
-
2.11
- 秒了
-
1.26
- 秒了
-
1.16
- 没太秒,但做出来了,哎,要是当时考这个就好了
-
11.11
- 秒了
class Solution {
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> res = new ArrayList<Integer>();
orderIn(root,res);
return res;
}
public void orderIn(TreeNode root,List<Integer> res){
if(root==null){
return;
}
orderIn(root.left,res);
res.add(root.val);
orderIn(root.right,res);
}- java中使用ArrayList<Integer>存结果,最后返回这个list,所以子方法中返回值为void
- 最后返回的是数组list,而不是方法orderIn