Loading...
Batman and the Riddler
Time: 1 s
Memory: 125 MB
Batman found a message from the Riddler, written as a string of lowercase letters of length N. He needs your help to change the string in this way:
  • If a character has appeared an odd number of times so far, convert it to lowercase.
  • If a character has appeared an even number of times so far, convert it to uppercase.
For example, if the letter 'a' appears 3 times, the 1st and 3rd times should be lowercase, and the 2nd should be uppercase.
Since Batman is lazy help him to output the string based on the above conditions.
Input
The first line contains N, the length of the string
The second line contains the string of length N
Constraint
1 <= N <= 1000
Output
Output a new string
Examples
Input
Output
6
batman
batmAn
Input
Output
7
riddler
ridDleR
Notes
In the first example:
  1. 'b' occured 1 time so far,  so it is lowercase: 'b'
  2.  'a' occured 1 time so far, so it is lowercase: 'a'
  3.  't' occured 1 time so far, so it is lowercase: 't'
  4. 'm' occured 1 time so far, so it is lowercase: 'm'
  5. 'a' occured 2 times so far , so it is uppercase: 'A' because 2 is even
  6. 'n' occurred 1 time so far, so it is lowercase: 'n'
Hence, the output is batmAn.
Problem Info
Problem ID 324
Time Limit 1000 ms
Memory Limit 128000 KB
Moderators Lost_Cause , mhmuhim , raj3100
Statistics
Submit
You need to Login or Registration for submit your solution