ntree.aiPlus One
Plus One
easysolvedattempted
You are given an array of integers digits, where each element is one digit and together they form a number.
The digits are ordered from the most significant to the least significant, and the number does not have leading zeros.
Add one to the number and return its digits as a new array.
Example 1:
Input: digits = [1, 4, 9, 9, 9]
Output: [1, 5, 0, 0, 0]
Explanation: 14999 + 1 == 15000.
Example 2:
Input: digits = [9, 9]
Output: [1, 0, 0]
Explanation: 99 + 1 == 100.
Constraints:
1 <= length of digits <= 1000 <= digits[i] <= 9
def plusOne(digits: list[int]) -> list[int]: pass Press Visualise to step through your code.