590. N-ary Tree Postorder Traversal
/*
// Definition for a Node.
class Node {
public int val;
public List children;
public Node() {}
public Node(int _val,List _children) {
val = _val;
children = _children;
}
};
*/
class Solution {
public List postorder(Node root) {
List out = new ArrayList();
postorder(root, out);
return out;
}
private void postorder(Node root, List out) {
if( null != root){
for (int i = 0; i < root.children.size(); i++)
postorder(root.children.get(i), out);
out.add(root.val);
}
}
}