(fList *ListNode, sList *ListNode)
| 36 | } |
| 37 | |
| 38 | func 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 | |
| 61 | func minValNode(fNode, sNode *ListNode) (*ListNode, bool) { |
| 62 | if sNode == nil { |
no test coverage detected