← 返回 amazon 的题目列表Minimize integer via operations
类型:online_judge
Given a string consisting of digits 1 through 9 such as "26547", perform the following operations:
Remove a digit from the string;
Increment this digit by 1;
Insert it back into any position in the string.
Repeat the operation until finding the smallest possible integer.
For instance, starting with "26547":
Remove 5, add 1 to get 6, insert to form 26467;
Remove 6, add 1 to get 7, insert to form 24677.
The result is "24677".
Example:
Input: "04829"
Output: "02599"
Example
Input
"04829"