N-ary Tree Postorder Traversal LeetCode solution in JavaScript

1
var postorder = function (root) {
2
const res = [];
3
function post(node) {
4
if (!node) return;
5
for (let child of node.children) {
6
post(child);
7
}
8
res.push(node.val);
9
}
10
post(root);
11
return res;
12
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0