#C904. Smallest Lexicographical String After At Most One Swap
Smallest Lexicographical String After At Most One Swap
Smallest Lexicographical String After At Most One Swap
Given a string text
consisting of only lowercase English letters, you are allowed to perform at most one swap between any two characters. The goal is to obtain the lexicographically smallest string possible. In other words, if you denote the string by \(s\), you need to find the smallest string \(s'\) such that \(s'\) is lexicographically smaller than or equal to \(s\) and can be obtained by swapping at most one pair of characters in \(s\).
If no swap operation can produce a smaller string, the original string should be returned unchanged.
inputFormat
A single line containing a string text
composed only of lowercase English letters.
outputFormat
Output the lexicographically smallest string that can be obtained after performing at most one swap.
## sampleabcdef
abcdef