FastPrepAdd One to a Number Represented as Digits
Problems/Add One to a Number Represented as Digits

Add One to a Number Represented as Digits

Oracle logoOracle● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source omits the callable interface and numeric bounds. The judged core task matches the visible source at about 95%.

You are given a non-empty integer array digits representing a non-negative decimal integer. The most significant digit appears first, and each array element is one digit.

Add one to the represented integer and return the resulting digit array. Do not convert the entire input to a numeric type or use a dynamic list.

The input has no leading zero unless it represents zero itself.

Function

plusOne(digits: int[]) → int[]

Examples

Example 1

digits = [1,2,9]return = [1,3,0]

Example 2

digits = [9,9,9]return = [1,0,0,0]

The carry creates a new most-significant digit.

Constraints

  • 1 <= digits.length <= 200000
  • 0 <= digits[i] <= 9
  • digits[0] != 0 unless digits.length = 1

More Oracle problems

  • Maximum Subarray Sum with One DeletionONSITE INTERVIEW · Seen Nov 2026
  • Shortest Deletion for Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
  • Count Dropped Rate-Limited RequestsONSITE INTERVIEW · Seen Nov 2026
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public int[] plusOne(int[] digits) {
      // Write your code here.
    }

}
Checking account…