Skip to content

Practice Plus One

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#66
LeetCode Problem

Plus One

Problem Statement

You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the resulting array of digits.

Source: Plus One on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
digits = [1,2,3]
Output
[1,2,4]

# Example 2

Input
digits = [4,3,2,1]
Output
[4,3,2,2]

# Example 3

Input
digits = [9]
Output
[1,0]

Constraints

1 <= digits.length <= 100
0 <= digits[i] <= 9
digits does not contain any leading 0's.

Related LeetCode Problems

Practice more problems similar to Plus One.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.