PIXELBANKv8.2.1
Menu

Add Two Numbers

Given two non-negative integers represented as arrays of digits in reverse order (least significant digit first), return their sum as an array in the same reverse order.

Each element contains a single digit. The numbers do not have leading zeros except the number 0 itself.

Output as space-separated digits.

Example:

Input:
2,4,3
5,6,4
Output:
7 0 8
Reasoning:
  • The input arrays represent numbers in reverse order: 2102+4101+3100=2432 \cdot 10^2 + 4 \cdot 10^1 + 3 \cdot 10^0 = 243 and 5102+6101+4100=5645 \cdot 10^2 + 6 \cdot 10^1 + 4 \cdot 10^0 = 564.
  • We add these two numbers: 243+564=807243 + 564 = 807.
  • To get the output, we convert the sum back to an array of digits in reverse order: 807807 becomes 77, 00, 88.
  • The final output is the sum as an array in the same reverse order, with space-separated digits: 7087 0 8.

Constraints:

  • 1 <= len(l1), len(l2) <= 100
  • 0 <= l1[i], l2[i] <= 9
Editor

Test Results

0/0
Run code to see test results.