Easy
Plus One
Easy
223 submissions
10 coins
+50 XP
Array
Math
Problem Description
A non-negative integer is stored as an array of its decimal digits, most significant first, with no leading zeros (except the number 0 itself). Add one to the number and return the resulting digit array.
**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`
Need help?
Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.
Video Call
Whiteboard
Live Coding
Screen Share