All submissions for this problem are available.
Wonderland Showroom is a a top neclace designer showroom in town . It's known for designing neclaces as customer wishes .A neclace is composed of a number of coloured beads. The colour of the beads is denoted by a lower case english alphabet for simplicity and design conventions. Alice is very fond of jewellery and wishes to purchase a "special" neclace on her birthday . Alice considers a neclace to be "special" if the following conditions are satisfied :
1. All the bead colours occurring odd number of times are placed first and then the bead colurs occurring even number of times.
2. The bead colors must also be in lexographically correct order.
3. All similar beads must occur together.
The Wonderland showroom has already pre-designed neclace sets. But to ensure that Alice purchases the neclace from their showroom they need to
redesign the neclaces to make it appear "special" . You are the chief designer in-charge.
Can you redesign the beads to make it appear special ?
Note: String A is lexicographically smaller than string B if at the first position where A and B differ A contains a letter which is earlier in the alphabet than the corresponding letter in B.
The first line contains a single positive integer T . T test cases follow. Each line of the test cases contains a string s.
For each test case output one line containing the "special" neclace that suits the requirements of Alice.
- 1<=Length of string<=1000
Input: 2 abaabccd aaaabbb Output: aaadbbcc bbbaaaa
Example case 1.
The frequency of each character is as follows
1. a occurs 3 times .
2. b occurs 2 times .
3. c occurs 2 times .
4. d occurs 1 times .
We need to place the beads occuring odd number of times at the beginning and in lexographical order.
'a' and 'd' are the only beads occuring odd number of times. 'a' occurs before 'd' in lexographical order.
So, we have ---> aaad
Now, we need to place the beads occuring even number of times and in lexographical order.
'b' and 'c' occur even number of times
So, we have ---> aaad + bbcc = aaadbbcc
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.