/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/funcaddTwoNumbers(l1*ListNode,l2*ListNode)*ListNode{dummy:=&ListNode{}node,carry:=dummy,0forl1!=nil||l2!=nil{ifl1!=nil{carry+=l1.Vall1=l1.Next}ifl2!=nil{carry+=l2.Vall2=l2.Next}node.Next=&ListNode{}node=node.Nextnode.Val=carry%10carry/=10}ifcarry!=0{node.Next=&ListNode{Val:carry}}returndummy.Next}
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/funcaddTwoNumbers(l1*ListNode,l2*ListNode)*ListNode{head:=&ListNode{-1,nil}cur:=headcarry:=0forl1!=nil||l2!=nil||carry!=0{ifl1!=nil{carry+=l1.Vall1=l1.Next}ifl2!=nil{carry+=l2.Vall2=l2.Next}cur.Next=&ListNode{Val:carry%10,Next:nil}cur=cur.Nextcarry/=10}returnhead.Next}