CT010

Add Two Spirit Numbers

MediumAcceptance: 0.0%

The Codetikki numerologists store digits in linked lists in reverse order, so the least significant digit comes first. They wish to add two such numbers. Given two linked lists representing two non-negative integers (digits stored in reverse order), return their sum as a linked list in the same format. Input: first line n and m (lengths), second line digits of first number, third line digits of second number. Output: space-separated digits of the sum in reverse order.

Example 1:

Input: 2 2 9 9 5 2
Output: 4 2 1

Example 2:

Input: 1 1 2 3
Output: 5

Constraints:

0 <= n, m <= 100 0 <= digit <= 9 No leading zeros except for the number 0 itself

Tags:

linked-list math recursion
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki