145. Binary Tree Postorder Traversal (E)
Last updated
Last updated
Given the root
of a binary tree, return the postorder traversal of its nodes' values.
Example 1:
Example 2:
Example 3:
Constraints:
The number of the nodes in the tree is in the range [0, 100]
.
-100 <= Node.val <= 100
Follow up: Recursive solution is trivial, could you do it iteratively?S
前文 手把手刷二叉树总结篇 说过二叉树的递归分为「遍历」和「分解问题」两种思维模式,分别代表回溯算法和动态规划的底层思想。
本题用两种思维模式来解答,注意体会其中思维方式的差异。
Version 3: Non-recursive with a stack:
Version 4: Non-recursive without stack
https://www.geeksforgeeks.org/postorder-traversal-binary-tree-without-recursion-without-stack/