Skip to main content

Practice · 1 of 1

Algorithmic Win: Count Once

sumUnique returns the sum of distinct values. The naive version sorts and scans, or worse, is O(n²). Implement it to run in **at most n long-long comparisons** by using an unordered_set — the grader counts comparisons via a tracked type.

Difficulty: advanced

Back to lesson: Practice: Practice: Algorithmic Wins