Skip to main content

Practice · 1 of 4

Generic swap and reverse

CHALLENGE
Difficulty: beginner+25 XP

Implement in Solution: static void Swap<T>(T[] items, int i, int j) swapping in place (throws ArgumentOutOfRangeException for out-of-range indices), and static T[] Reversed<T>(T[] items) returning a NEW array in reverse order (null/empty → empty array, never null).

Back to lesson: Practice: Generics workout