function levelOrder(root) {
let queue = [root], result = [];
function process(node) {
result.push(node.val);
}
while (queue.length) {
const node = queue.pop();
process(node);
if (node.left) queue.unshift(node.left);
if (node.right) queue.unshift(node.right);
}
return result; //?
}
Categories