题意以及限制条件
-
题目:
-
限制条件:
想到的所有可能解法
-
Ways_1——递归
- 时间复杂度——O(n);空间复杂度——O(n)。
对应的代码
- Ways_1
class Solution {
public List<Integer> postorder(Node root) {
//Terminator
if (root == null) return res;
//Current Logic
for (Node node : root.children) {
//Drill Down
postorder(node);
}
//Current Logic
res.add(root.val);
return res;
//Restore Current Data
}
private List<Integer> res = new ArrayList<Integer>();
}