Plus One Problem

Plus One Problem — ExecCode Easy DSA Practice

Solve the Plus One problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit. Increment the large integer by one and return the resulting array of digits.

Examples

Input digits = [1, 2, 3]; Output [1, 2, 4]. Input digits = [9, 9]; Output [1, 0, 0]

Constraints

1 ≤ digits.length ≤ 100 0 ≤ digits[i] ≤ 9 digits does not contain leading zeroes except for 0 itself

Practice Plus One free on ExecCode. Browse DSA problems, topic map, and placement guides.