UVa 10789

From Algorithmist
Jump to navigation Jump to search

10789 - Prime Frequency[edit]

Summary[edit]

Given a string find the characters a-z A-Z 1-9 that have a prime frequency in the string

Explanation[edit]

Generate a mapping of the ascii characters to their frequency. Use precomputed primes to figure out whether the frequency of the ascii character is a prime

Implementations[edit]

Input[edit]

4
ABCC
AABBBBDDDDD
AAaa11
ABCDFFFF

Output[edit]

Case 1: C
Case 2: AD
case 3: 1Aa
Case 4: empty