Count frequency of each character in the input string

Asked atSBS
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Clarify case, whitespace, and character set rules.
  2. 02Initialize a frequency map or bounded array.
  3. 03Increment once per character.
  4. 04Preserve a requested output order.
  5. 05State encoding and complexity assumptions.

Reference answer

Then expect these follow-ups

  • Should 'A' and 'a' be combined?

    Tests: follow-up reasoning

  • How would you count Unicode grapheme clusters?

    Tests: implementation extension

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question