Skip to main content

Practice · 4 of 6

Backward-looking dedup

CHALLENGE
Difficulty: intermediate+25 XP

Implement int countDistinct(int[] arr): number of distinct values. The pairwise backward scan (j < i, break on first match) is allowed and expected. Empty array → 0.

Back to lesson: Practice: Array lab