Jumlah Dua Daftar Tertaut Jika angka dibalik dalam daftar tertaut
def sum_two_lists(self, llist):
cur = self.head
cur1 = llist.head
n1 = 0
n2 = 0
remainder = 1
while cur:
n1 += (cur.data) * remainder
remainder *= 10
cur = cur.next
remainder = 1
while cur1:
n2 += (cur1.data) * remainder
remainder *= 10
cur1 = cur1.next
total = str(n1 + n2)[::-1]
answer = LinkedList()
for i in total:
answer.append(i)
return answer
Defiant Donkey