Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Plus One

Easy

Topics
ArrayMath

You are given a large integer as an array of digits digits (most significant first). Increment it by one and return the resulting digits.

Example 1

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

Example 2

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

Constraints

  • 1 <= digits.length <= 100
  • 0 <= digits[i] <= 9
  • No leading zeros (except the number 0).
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access