Skip to main content

Practice · 2 of 5

Trust the precondition

CHALLENGE
Difficulty: intermediate+25 XP

Implement double median(int[] arr) for a SORTED array (length >= 1 promised): odd length → middle element; even length → average of the two middle elements. The precondition means you may NOT need an empty check — but you DO need the parity case split.

Back to lesson: Practice: Specification workshop