Description
The array-form of an integer num is an array representing its digits in left to right order. Given num represented as an array and an integer k, return the array-form of num + k.
Examples
Input:
num = [1,2,0,0], k = 34Output:
[1,2,3,4]Explanation:
1200 + 34 = 1234.
Input:
num = [9,9,9], k = 1Output:
[1,0,0,0]Explanation:
999 + 1 = 1000. This demonstrates the carry-over case where adding a small number causes multiple digits to roll over, increasing the total number of digits in the result.
Input:
num = [5], k = 237Output:
[2,4,2]Explanation:
5 + 237 = 242. This shows how adding a multi-digit number to a single-digit array-form integer works, where k is larger than the original number represented by the array.
Constraints
- •
1 ≤ num.length ≤ 10⁴