/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function Print(pRoot) { // write code here //先遍历 if(pRoot===null) return [] let res = [] let arr = [] arr.push(pRoot) while(arr.length>0){ let newArr = [] let res1 = [] arr.forEach(v=>{ res1.push(v.val) v.left&&newArr.push(v.left) v.right&&newArr.push(v.right) }) arr = newArr res.push(res1) } for(i = 0;i<res.length;i++){ if(i%2!=0){ res[i].reverse() } } return res } module.exports = { Print : Print };