-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflatten_test.go
33 lines (26 loc) · 918 Bytes
/
flatten_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package flatten
import "testing"
func TestFlatten(t *testing.T) {
head := &ListNode{}
head.Val = 1
head.Next = &ListNode{Val: 2, Prev: head}
head.Next.Next = &ListNode{Val: 3, Prev: head.Next}
head.Next.Next.Next = &ListNode{Val: 4, Prev: head.Next.Next}
head.Next.Next.Next.Next = &ListNode{Val: 5, Prev: head.Next.Next.Next}
head.Next.Next.Next.Next.Next = &ListNode{Val: 6, Prev: head.Next.Next.Next.Next}
headchild1 := &ListNode{Val: 7}
headchild1.Next = &ListNode{Val: 8, Prev: headchild1}
headchild1.Next.Next = &ListNode{Val: 9, Prev: headchild1.Next}
headchild1.Next.Next.Next = &ListNode{Val: 10, Prev: headchild1.Next.Next}
headchild2 := &ListNode{Val: 11}
headchild2.Next = &ListNode{Val: 12, Prev: headchild2}
headchild1.Next.Child = headchild2
head.Next.Next.Child = headchild1
r := flatten(head)
re := []int{}
for r != nil {
re = append(re, r.Val)
r = r.Next
}
t.Log(re)
}