Given a bank account balance, remove at most one digit from its decimal representation to make the resulting number as large as possible.
Ilya has a bank account balance that may be negative. He is allowed to delete at most one digit from the decimal representation of the number in order to maximize the final value.
If the number is negative, removing a digit can change the magnitude and therefore the value. The goal is to choose the best possible digit to delete, or delete nothing if that is already optimal.
Return the maximum possible value after this operation.
You are working with the number as a string of digits (with an optional leading -). The task is to try the best single deletion and keep the numerically largest outcome.
The input contains a single integer .
Print one integer — the maximum value that can be obtained after deleting at most one digit.
Example 1
Input
512
Output
52
Explanation
Deleting 1 gives 52, which is larger than deleting any other digit or keeping the number unchanged.
Example 2
Input
-7605
Output
-605
Explanation
Since the number is negative, we want the value closest to zero. Deleting 7 gives -605, which is better than deleting any other digit.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.