Skip to main content

Practice · 1 of 6

Second distinct maximum

CHALLENGE
Difficulty: advanced+25 XP

Return the **second distinct maximum** value; return -1 if it does not exist (fewer than two distinct values, or empty). Implement process(int[] arr). Examples: {4,1,4,2} → 2 (4 repeats count once), {5,5} → -1, {} → -1.

Back to lesson: Practice: Array lab: two passes, write indices, safe removal