#C6026. Remove One Digit for Minimum Value
Remove One Digit for Minimum Value
Remove One Digit for Minimum Value
You are given a string S consisting of digits from 0 to 9. Your task is to remove exactly one digit from S in order to form the smallest possible integer (represented as a string). Note that the resulting string might contain leading zeros.
The strategy is as follows: traverse the string from left to right. If you find an index i such that the digit at position i is greater than the digit immediately following it (i.e. S[i] > S[i+1]), remove S[i]. If no such index exists, remove the last digit. In mathematical terms, if the input string is represented as S, then the resulting string is:
[ result = \begin{cases} S[0:i] + S[i+1:], & \text{if } S[i] > S[i+1] \text{ for some } i, \ S[0:n-1], & \text{otherwise.} \end{cases} ]
This removes exactly one digit and guarantees the smallest possible resulting value.
inputFormat
The input consists of a single line containing a non-empty string S of digits (0-9), with a length of at least 2.
outputFormat
Output the smallest possible number (as a string) obtained by removing exactly one digit from S. The output should be printed to standard output.
## sample1524
124