AmazonOA #146
Find Encrypted Password (A.K.A Compute Encoded Product Name
Estimated EasyJudge-ready
The input is guaranteed to be a lowercase palindrome. Rearrange all of its characters to get the lexicographically smallest password that is still a palindrome.
Input
One line with a lowercase palindrome of length 1..100000.
Output
Output the lexicographically smallest palindrome after rearrangement.
Example 1
Input:
babab
Output:
abbba
Example 2
Input:
yxxy
Output:
xyyx
Example 3
Input:
ded
Output:
ded
Example notes
Example 1: the left half is ab and the middle is b, which mirrors to abbba. Example 2: the left half is xy, giving xyyx. Example 3: the sides can only be d and the middle e, so it stays ded.
Editorial
Loading solution…