PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''
linked list adding for Python
Coded by Marco Abrate 2017
Challenge by Kartikey Sahu
Challenge: Add two numbers in Linked List
You are given two non-empty linked lists representing 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.
Input: (2, 4, 3) + (5, 6, 4)
Output: (7, 0, 8)
Input: (3, 6) + (1, 7, 5)
Output: (4, 3, 6)
Input: (5) + (5)
Output: (0, 1)
'''
# input two linked lists without parentheses
# example: 2,4,3
# 5,6,4
lst1=tuple(map(int,input('').split(',')))
lst2=tuple(map(int,input('').split(',')))
def tonum(lst):
num=0
for i in range(len(lst)):
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run