Next growing number
Statement
Goal
A growing number is a number where each digit, from left to right, is greater than or equal to the previous one.Given a number n, which may or may not be a growing number, you have to find the first growing number > n.
Example:
With n = 19, the first growing number greater than n is 22, because both 20 and 21 have a second digit that is smaller than the first one.
Note: This problem can be solved without converting n to a number.
Input
line 1: a string representing the number n
Output
line 1: the first growing number > n
Constraints
n < 10^19
Example
Input
19
Output
22
Tags
Numbers
Difficulty
Easy
Test cases
Test 1 Test
Input
19
Output
22
Validator 1 Validator
Input
9
Output
11
Test 2 Test
Input
99
Output
111
Validator 2 Validator
Input
199
Output
222
Test 3 Test
Input
2533
Output
2555
Validator 3 Validator
Input
3625
Output
3666
Test 4 Test
Input
123456879
Output
123456888
Validator 4 Validator
Input
223456789
Output
223456799
Test 5 Test
Input
11123159995399999
Output
11123333333333333
Validator 5 Validator
Input
1124222555666499999
Output
1124444444444444444
Solution language
Solution
Stub generator input