FastPrepPlus One
Problems/Plus One

Plus One

Druva logoDruva● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In the third round, the interviewer asked the candidate to add one to a number stored as an array of digits, explain the idea, and then write the code. The report links the problem but does not restate it.

The report gives no limits. Here, the digits go from most significant to least significant. There is no leading zero except for the number 0 itself. The array can hold up to 1,000 digits, so the number does not fit in a 64-bit integer.

Our version is about 90% the same as the reported question.

You are given a non-negative integer as an array digits. Each element is one digit from 0 to 9. The digits go from the most significant digit (first) to the least significant digit (last).

Add one to the integer and return the digits of the result in the same form.

The array has no leading zeros, except when the integer is 0 itself, which is given as [0].

Function

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

Examples

Example 1

digits = [1,2,3]return = [1,2,4]

The array stands for 123. The last digit 3 becomes 4, and nothing is carried, so the answer is [1,2,4].

Example 2

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

The array stands for 199, and 199 + 1 = 200. Both trailing 9s become 0, and the carry turns the leading 1 into 2.

Example 3

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

The array stands for 999, and 999 + 1 = 1000. Every digit becomes 0, so a new leading 1 is added and the answer has four digits.

Constraints

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

More Druva Onsite Interview questions

  • Remove Nth Node From End of ListONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Rotate a Flat Image ClockwiseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Matrix MultiplicationeBay · ONSITE INTERVIEWeBay interview questions
  • Maximum Product of Three IntegersPelatro · ONSITE INTERVIEW
  • Exact-Sixty Dice Game ValueJane Street · ONSITE INTERVIEWJane Street interview questions
  • Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
  • Alternating Index Square SumAccenture · ONSITE INTERVIEWAccenture interview questions
  • Moving Cost by Volume and CategoryWayfair · ONSITE INTERVIEWWayfair interview questions
  • Add One to a Number Represented as DigitsOracle · ONSITE INTERVIEWOracle interview questions
  • Streaming Entropy, Part 1: Batch EntropyOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Majority ElementMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
See Druva hiring insights
Saved
class Solution {
    public int[] plusOne(int[] digits) {
        // Write your solution here.
    }
}
Checking account…