#C10706. Remove and Minimize

    ID: 39941 Type: Default 1000ms 256MiB

Remove and Minimize

Remove and Minimize

Given a string \(S\) and a character \(ch\), remove exactly one occurrence of \(ch\) from \(S\) so that the resulting string is the lexicographically smallest possible.

If the character \(ch\) does not appear in \(S\), output \(S\) unchanged.

The lexicographical order is defined by the standard string comparison.

Note: When multiple occurrences of \(ch\) are present, you must consider removing each and choose the smallest outcome.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains the string \(S\) (with length at least 1).
  • The second line contains the character \(ch\).

outputFormat

Output to standard output (stdout) the lexicographically smallest string obtained by removing exactly one occurrence of \(ch\) from \(S\). If \(ch\) is not present in \(S\), output \(S\) unchanged.

## sample
abcabc
b
abcac