数据结构与算法--之树的后序遍历(递归方式)
作者:互联网
public List postorderTraversal(TreeNode root) {
LinkedList ans = new LinkedList<>();
inoder(root,ans);
return ans;
}
public void inoder(TreeNode root,List<Integer> list){
if(root==null)return;
inoder(root.left,list);
inoder(root.right,list);
list.add(root.val);
}
标签:遍历,return,LinkedList,--,list,之树,ans,root,inoder 来源: https://blog.csdn.net/qq_19520877/article/details/118864080