Skip to main content

Checkpoint: stable partition

Challenge on lesson: Checkpoint: stable partition

CHALLENGE
Difficulty: intermediate+25 XP

Implement void partition(int[] arr): reorder in place so values smaller than the pivot (arr's first element) come first, then the pivot itself, then everything else โ€” preserving relative order. {5, 2, 8, 1, 9, 5} โ†’ {2, 1, 5, 8, 9, 5}. The count-then-act shape with a pivot slot is one clean solution.

Back to lesson: Checkpoint: stable partition