var levelOrder = function(root) {
let q = [root], ans = []
while (q[0]) {
let qlen = q.length, row = []
for (let i = 0; i < qlen; i++) {
let curr = q.shift()
row.push(curr.val)
if (curr.left) q.push(curr.left)
if (curr.right) q.push(curr.right)
}
ans.push(row)
}
return ans
};
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)