* function TreeNode(x) {
* this.val = x;
* this.left = null;
* this.right = null;
* }
*/
/**
*
* @param root TreeNode类
* @return int整型二维数组
*/
function levelOrder( root ) {
// write code here
if(!root) return [];
let queue = [root];
let res = [];
while(queue.length) {
let level = [];
let size = queue.length;
while(size--) {
let cur = queue.shift();
level.push(cur.val);
if(cur.left) queue.push(cur.left);
if(cur.right) queue.push(cur.right);
}
res.push(level);
}
return res;
}
module.exports = {
levelOrder : levelOrder
};