You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

Example:

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

 

# coding=utf-8

a=[2,4,3]
b=[5,6,4]

a.reverse()
b.reverse()
c=0
str1=""
str2=""

for i in a:
str1+=str(i)
for j in b:
str2+=str(j)
c=int(str1)+int(str2)
print(c)

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄