cswork / OAOpen practice workspace

MicrosoftOA #26

Get Alphabetically Smallest String

Estimated EasyJudge-ready

Topics (AI-labelled)GreedyStrings

Delete exactly one character from a lowercase string and return the lexicographically smallest remaining string.

Input

One line of 2..100000 lowercase letters.

Output

Output the smallest string obtainable by deleting one character.

Example 1

Input:

acb

Output:

ab

Example 2

Input:

hot

Output:

ho

Example 3

Input:

aaaa

Output:

aaa

Example notes

Example 1: deleting c gives ab, which is smaller than ac and cb.

Example 2: the string is non-decreasing, so deleting the last t gives ho.

Example 3: deleting any a gives aaa.

Editorial

Loading solution…