Skip to main content

Practice · 4 of 5

In-place reversal

CHALLENGE
Difficulty: intermediate+25 XP

Implement void reverse(int[] arr): reverse the array in place using swaps — no new array. Odd-length arrays have a untouched middle element. Trace {1,2,3,4} swap by hand: (0,3) then (1,2).

Back to lesson: Practice: Specification workshop