Practice/Meta/Leetcode 94. Binary Tree Inorder Traversal
CodingMust
Given the root of a binary tree, return the values of its nodes in postorder traversal sequence.
In postorder traversal, you visit nodes in this order:
While a recursive solution is straightforward, can you implement this iteratively using an explicit stack?
Example 1:
Input: root = [1, null, 2, 3] Tree structure: 1 \ 2 / 3 Output: [3, 2, 1] Explanation: Visit left child of 2 (which is 3), then node 2, then root 1
Example 2:
Input: root = [] Output: [] Explanation: Empty tree has no nodes to traverse
Example 3:
Input: root = [1] Output: [1] Explanation: Single node is visited once
Example 4:
Input: root = [1, 2] Tree structure: 1 / 2 Output: [2, 1] Explanation: Visit left child 2 first, then root 1