Program
Given a binary tree, return the postorder traversal of its nodes’ values.
Example
1 | Input: [1,null,2,3] |
Solution1
Method: Depth-first Search (Recursive)
Time Complexity: O(n)
Space Complexity: O(n)
1 | # Definition for a binary tree node. |
Solution2
Method: Depth-first Search (Iterative)
Time Complexity: O(n)
Space Complexity: O(n)
1 | # Definition for a binary tree node. |