This is simplest Java solution ever Possible


  • -2
    R
    public class Solution {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> rslt = new ArrayList<Integer>();
        
        posttr(root, rslt);
        return rslt;
    }
    
    void posttr(TreeNode root, List<Integer> rslt){
        
        if(root == null)
         return ;
        
        posttr(root.left, rslt);
        posttr(root.right, rslt);
        rslt.add(root.val);
        
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.