Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Plus One

XPChallenge Points: 10
levelLevel: Easy

You are provided with a list of digits forming an integer (no leading zeros).
Return the resulting list after adding one to the represented integer.
If the addition causes a carry-over (like 999 + 1 = 1000), handle it properly.

Example 1:

Input: digits = [7,5,9]

Output: [7,6,0]

Explanation:

759 + 1 = 760

Example 2:

Input: digits = [9,9]

Output: [1,0,0]

Explanation:

99 + 1 = 100

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