题目:
题解:
func connect(root *Node) *Node {start := rootfor start != nil {var nextStart, last *Nodehandle := func(cur *Node) {if cur == nil {return}if nextStart == nil {nextStart = cur}if last != nil {last.Next = cur}last = cur}for p := start; p != nil; p = p.Next {handle(p.Left)handle(p.Right)}start = nextStart}return root
}