/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/funcmergeTwoLists(l1*ListNode,l2*ListNode)*ListNode{ifl1==nil||l2==nil{ifl1==nil{returnl2}returnl1}ifl1.Val<l2.Val{l1.Next=mergeTwoLists(l1.Next,l2)returnl1}else{l2.Next=mergeTwoLists(l1,l2.Next)returnl2}}
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/funcmergeTwoLists(l1*ListNode,l2*ListNode)*ListNode{dummy:=&ListNode{}cur:=dummyforl1!=nil&&l2!=nil{ifl1.Val<l2.Val{cur.Next=l1l1=l1.Next}else{cur.Next=l2l2=l2.Next}cur=cur.Next}ifl1!=nil{cur.Next=l1}else{cur.Next=l2}returndummy.Next}