JOIN
Get Time

   Problem Statement  

 Problem Statement for AntiPalindrome

Problem Statement

    

A String p is called anti-palindrome if p[i] doesn't equal to p[n - i - 1] for each 0 <= i < (n-1)/2, where n is the length of p. It means that each character (except the middle in the case of a string of odd length) must be different from its symmetric character. For example, "c", "cpp", "java" are anti-palindrome, but "test", "pp" and "weather" are not.

You are given a String s. Rearrange its letters in such a way that the resulting string is anti-palindrome. If there are several solutions, return the one that comes earliest alphabetically. If it is impossible to do it, return the empty string.

 

Definition

    
Class:AntiPalindrome
Method:rearrange
Parameters:String
Returns:String
Method signature:String rearrange(String s)
(be sure your method is public)
    
 

Constraints

-s will contain between 1 and 50 characters, inclusive.
-s will contain only lowercase letters ('a'-'z').
 

Examples

0)
    
"test"
Returns: "estt"
1)
    
"aabbcc"
Returns: "aabcbc"
2)
    
"reflectionnoitcelfer"
Returns: "cceeeeffiillnnoorrtt"
3)
    
"hello"
Returns: "ehllo"
4)
    
"www"
Returns: ""

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.

This problem was used for:
       2007 TopCoder Open Online Round 1B - Division I, Level One
       2007 TopCoder Open Sponsor Track Round 1 - Division I, Level One