/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ funclevelOrder(root *TreeNode) [][]int { // 层序遍历 使用size 记录每层数组 queue node 队列
res := make([][]int, 0) queue := make([]*TreeNode, 0)
if root != nil { queue = append(queue, root) } else { return res }