cswork / OAOpen practice workspace

IntuitOA #19

Rearrange String

Estimated HardStatement and editorial — judging is being prepared

Topics (AI-labelled)GreedyHashing

You have a string S. Your task is to rearrange some characters of the string (if needed) so that S[i] is not equal to S[L - i - 1] for each 0 Input The input contains the string S`. Output Print 'impossible' if there is no answer. Otherwise, print a lexicographical first string that satisfies the given requirements.

Constraints

1 ≤ L ≤ 10⁴

Example 1

Input:

s = "abca"

Output:

"aabc"

Explanation: No explanation is provided for now As always, I will add it once find any. Or if you happen to know about it, feel free to dm Groot! Many thanks in advance!

Editorial

Loading solution…