Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Add to Array-Form of Integer

XPChallenge Points: 10
levelLevel: Easy

You are given an integer represented as an array of digits in left-to-right order.
For example, the number 1321 is stored as [1, 3, 2, 1].

Your task is to add an integer k to this digit-array number and return the resulting number in the same array-form.
The answer should also be returned as an array of digits from most significant to least significant.

Example 1:

Input: num = [9, 9, 9], k = 1

Output: [1, 0, 0, 0]

Explanation:

999 + 1 = 1000

Example 2:

Input: num = [3, 4, 5], k = 555

Output: [9, 0, 0]

Explanation:

345 + 555 = 900

Example 3:

Input: num = [0], k = 73

Output: [7, 3]

Explanation:

0 + 73 = 73

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result