func levelOrder(root *TreeNode) []int {
if root == nil {
return nil
}
res := []int{}
queue := []*TreeNode{root}
for len(queue) != 0 {
temp := []*TreeNode{}
for _, node := range queue {
res = append(res, node.Val)
if node.Left != nil {
temp = append(temp, node.Left)
}
if node.Right != nil {
temp = append(temp, node.Right)
}
}
queue = temp
}
return res
}