The Question
Coding
Minimum Swaps for Couple Pairing
Given an array of $2n$ integers representing $n$ couples $(2k, 2k+1)$ sitting in $2n$ seats, find the minimum number of swaps required so that every couple sits in adjacent seats (indices $(0,1), (2,3), \dots$). A swap allows exchanging the seats of any two people.
Java
Greedy
Union-Find
Graph Theory
Hash Map
March 4, 2026