Golang | Leetcode Golang题解之第429题N叉树的层序遍历
题目:
题解:
func levelOrder(root *Node) (ans [][]int) {if root == nil {return}q := []*Node{root}for q != nil {level := []int{}tmp := qq = nilfor _, node := range tmp {level = append(level, node.Val)q = append(q, node.Children...)}ans = append(ans, level)}return
}