Skip to content

Commit 2b9bbc0

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents 39aba0b + cbec484 commit 2b9bbc0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
type ListNode struct {
2+
Val int
3+
Next *ListNode
4+
}
5+
6+
func mergeTwoLists(list1 *ListNode, list2 *ListNode) *ListNode {
7+
if list1 == nil {
8+
return list2
9+
}
10+
if list2 == nil {
11+
return list1
12+
}
13+
14+
if list1.Val < list2.Val {
15+
list1.Next = mergeTwoLists(list1.Next, list2)
16+
return list1
17+
}
18+
list2.Next = mergeTwoLists(list1, list2.Next)
19+
return list2
20+
}

0 commit comments

Comments
 (0)