Account
Draft saved on this device
▤ DescriptionOriginal CppValley problem
Core C++Easy

Compute Word Frequencies With Unordered Map

Count how many times each input word occurs.

Count how many times each input word occurs. Print each distinct word and its frequency in lexicographic (ascending) order. Words contain lowercase ASCII letters only; comparisons are case-sensitive.

Input format

First line N; next N whitespace-delimited words.

Output format

One line per distinct word: word count, sorted lexicographically.

Examples

Example 1
Input
5
cat dog cat bird dog
Expected output
bird 1
cat 2
dog 2

Constraints

  • 0 ≤ N ≤ 100000
  • 1 ≤ each word length ≤ 50

Related concepts

Hash Maps

This early-access exercise uses standard input/output. More advanced concurrency challenges will use specialized class interfaces, instrumentation, and stress tests once the judging infrastructure is ready.

⌘ CodeC++17
GNU C++17 · main.cpp

Loading Monaco C++ editor…

Checking judge...

Checking whether the external C++ judge is available.

⌁ Test cases & resultsPublic samples: 1
Input
5
cat dog cat bird dog
Expected output
bird 1
cat 2
dog 2
Execution requires a secure external judge.