5 lines accepted solution with recursion


  • 0
    N
    public class Solution {
        public IList<int> result = new List<int>();
        public IList<int> PostorderTraversal(TreeNode root) 
        {
            if(root != null)
            {
                PostorderTraversal(root.left);
                PostorderTraversal(root.right);
                result.Add(root.val);
            }
            return result;
        }
    }
    

Log in to reply
 

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