
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Plus One
								Certification: Basic Level
								Accuracy: 0%
								Submissions: 1
								Points: 5
							
							Write a C program to increment a large integer represented as an array of digits by one. Given a non-empty array of decimal digits representing a non-negative integer, increment the integer by one and return the resulting array of digits. The most significant digit is at the first position of the array.
Example 1
- Input: digits = [1, 2, 3]
 - Output: [1, 2, 4]
 - Explanation: The array [1, 2, 3] represents the integer 123. Adding 1 gives 124, which is represented as [1, 2, 4].
 
Example 2
- Input: digits = [9, 9, 9]
 - Output: [1, 0, 0, 0]
 - Explanation: The array [9, 9, 9] represents the integer 999. Adding 1 gives 1000, which is represented as [1, 0, 0, 0].
 
Constraints
- 1 ≤ digits.length ≤ 100
 - 0 ≤ digits[i] ≤ 9
 - digits does not contain any leading zeros, except the number 0 itself
 - Time Complexity: O(n)
 - Space Complexity: O(n)
 
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Start from the least significant digit (rightmost)
 - Add 1 to the digit and check if it becomes 10
 - If it becomes 10, set it to 0 and carry 1 to the next digit
 - Continue this process until there is no carry or no more digits
 - If there is still a carry after processing all digits, add a new digit 1 at the beginning of the array