← November 2025 questions

NOVEMBER 2025 / INTERMEDIATE / QUESTION 4

Frequency Sorter

Archived question

Try the question in your own editor, then check your output below.

THE QUESTION

Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.

You are a worker at Alphaland Gym Houston. The member attendance data is
stored as a string. Rearrange its characters so that letters with higher frequency
appear first. If two characters have the same frequency, sort alphabetically.
Sample Input:
10
kanghaerin
Sample Output:
aanneghikr
Question Input:
30
steaenltrseateoaristtehnasdeih

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Use the question input above. Enter only the output.

Reveal worked answer

Your output

eeeeeetttttaaaasssshhiinnrrdlo

Count letters; order them by decreasing frequency and alphabetically for tied counts.

Source: Girls in Code SEA 2025 Fall Competition, 29 November 2025. Booklet created by Emily Xu and the GIC question authors. Shared for non-commercial educational use with attribution, as permitted in the booklet.