标签:next == class lis turn amp pre tmp golang
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode { if l1 == nil { return l2 } if l2 == nil { return l1 } prehead := &ListNode{Val:0} cur := prehead jw := 0 for l1!=nil || l2 != nil { v1 := 0 v2 := 0 if l1!=nil{ v1=l1.Val l1=l1.Next } if l2!=nil{ v2=l2.Val l2=l2.Next } tmp:=v1+v2+jw cur.Next=&ListNode{Val:tmp%10} cur=cur.Next jw=tmp/10 } if jw!=0 { cur.Next=&ListNode{Val:jw} } return prehead.Next }
标签:next == class lis turn amp pre tmp golang
原文地址:https://www.cnblogs.com/transfercai/p/10529476.html