Modify The String

3.7

3 votes
Basic Programming, Hiring, Sorting, Algorithms, Hash function, Easy,
Problem

You are given with a string S of length N. You have to sort the string S in such a way that when individual characters are converted to their ASCII values, they should follow given rules :

  • Characters possessing prime ASCII value should come before characters possessing composite ASCII value.
  • If two characters are having prime ASCII value, character having less ASCII should come before other.
  • If two characters are having composite ASCII value, character having greater ASCII value should come before other.

Input format

  • The first line of input contains the length of string S.
  • The second line of input contains string S.

Output format

The single line of output should contain required modified String.

Constraints

  • 1Length(S)105
  • 33ASCIIvalueofcharacter126

 

Sample Input
13
Khokharnikunj
Sample Output
akkuronnjihhK
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

for primes : a < k

for Composite : K < h < i < j < n < o < r < u

Adding up logic , required answer is akkuronnjihhK

Editor Image

?