TopCoder problem "PalindromeMaker" used in SRM 274 (Division I Level One , Division II Level Two)



Problem Statement

    

A palindrome is a string that is spelled the same forward and backward. We want to rearrange letters of the given string baseString so that it becomes a palindrome.

You will be given a String baseString. Return the palindrome that can be made from baseString. When more than one palindrome can be made, return the lexicographically earliest (i.e., the one that occurs first in alphabetical order). Return "" (the empty string) if no palindromes can be made from baseString.

 

Definition

    
Class:PalindromeMaker
Method:make
Parameters:String
Returns:String
Method signature:String make(String baseString)
(be sure your method is public)
    
 

Constraints

-baseString will contain between 1 and 50 characters, inclusive.
-Each character in baseString will be an uppercase letter ('A'-'Z').
 

Examples

0)
    
"AABB"
Returns: "ABBA"
1)
    
"AAABB"
Returns: "ABABA"
2)
    
"ABACABA"
Returns: "AABCBAA"
3)
    
"ABCD"
Returns: ""

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=5881

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=8071&pm=5881

Writer:

Andrew_Lazarev

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Brute Force, Sorting