Practice · 4 of 4
Debug: doubled max
CHALLENGE
Difficulty: beginner+25 XP
twiceMax(int[] a) should return 2 * the largest element. It compiles, always terminates, and returns 2 * a[0] whenever the max exists — wrong whenever the max is not first. Repair it (keep the two-loop shape if you like).
Press Submit to check your solution.
Back to lesson: Practice: Algorithmic reasoning reps