Add Numbers Represented as Arrays
Add Numbers Represented as Arrays
Add two numbers where each number is represented as an array of digits.
Requirements:
- Each array represents a number (e.g., [1,2,3] = 123)
- Add the two numbers
- Return result as array
- Handle carry-over
Example:
Input: [1,2,3], [4,5,6]
Output: [5,7,9]
Explanation: 123 + 456 = 579
Input: [9,9,9], [1]
Output: [1,0,0,0]
Explanation: 999 + 1 = 1000
Examples:
Input 1:
{"arr1":[1,2,3],"arr2":[4,5,6]}Output 1:
[5,7,9]Input 2:
{"arr1":[9,9,9],"arr2":[1]}Output 2:
[1,0,0,0]Loading editor...
Run your code to see results
Click the Run button above