MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / mergeTwoLists

Function mergeTwoLists

tasks/23.go:38–59  ·  view source on GitHub ↗
(fList *ListNode, sList *ListNode)

Source from the content-addressed store, hash-verified

36}
37
38func mergeTwoLists(fList *ListNode, sList *ListNode) *ListNode {
39 // var min *ListNode
40 var head *ListNode
41 var current *ListNode
42 for fList != nil || sList != nil {
43 min, isFirst := minValNode(fList, sList)
44 if isFirst {
45 fList = fList.Next
46 } else {
47 sList = sList.Next
48 }
49 if head == nil {
50 head = min
51 current = head
52 continue
53 }
54 current.Next = min
55 current = current.Next
56
57 }
58 return head
59}
60
61func minValNode(fNode, sNode *ListNode) (*ListNode, bool) {
62 if sNode == nil {

Callers 1

mergeKListsFunction · 0.70

Calls 1

minValNodeFunction · 0.70

Tested by

no test coverage detected