Add to Array-Form of Integer

Given an array-form integer and an integer K, add K to the array-form integer and return the result as an array. Pattern focus: Bit Addition. Process digits from the end and carry forward just like binary addition, but with base 10 digits.

Input Format

num = array-form integer, k = integer to add

Output Format

resulting integer in array form

Constraints

  • 1 <= input size <= 10^5
  • -10^9 <= numeric values <= 10^9
  • num, k must satisfy the format described in inputFormat.

Examples

Example 1:

Input:

num = [1,2,0,0]
k = 34

Output:

[1,2,3,4]

Explanation:

1200 + 34 = 1234.

Example 2:

Input:

num = [2,7,4]
k = 181

Output:

[4,5,5]

Explanation:

274 + 181 = 455.

Loading...
Add to Array-Form of Integer - Bit Manipulation