Skip to main content

Practice · 1 of 5

Most Frequent Value

CHALLENGE
Difficulty: beginner+25 XP

**Description:** Given n integers with values 0..10^6, print the value that appears most often. If several tie, print the **smallest** such value. **Input:** Line 1: n (1 ≤ n ≤ 10^5). Line 2: n integers (0 ≤ each ≤ 10^6). **Output:** One integer. **Example:** 5 / 2 3 2 3 1 → 2 (2 and 3 both appear twice; 2 is smaller).

Back to lesson: Practice: Marking Array Set