Skip to content

Commit

Permalink
Merge branch 'DaleStudy:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
eunhwa99 authored Jan 4, 2025
2 parents 39aba0b + cbec484 commit 2b9bbc0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions merge-two-sorted-lists/changchanghwang.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type ListNode struct {
Val int
Next *ListNode
}

func mergeTwoLists(list1 *ListNode, list2 *ListNode) *ListNode {
if list1 == nil {
return list2
}
if list2 == nil {
return list1
}

if list1.Val < list2.Val {
list1.Next = mergeTwoLists(list1.Next, list2)
return list1
}
list2.Next = mergeTwoLists(list1, list2.Next)
return list2
}

0 comments on commit 2b9bbc0

Please sign in to comment.