Couples Holding Hands
N couples sit in 2N seats arranged in a row. You want every couple to sit side by side. Couples are numbered (0,1), (2,3), etc. A swap consists of choosing any two people and having them swap seats. Return the minimum number of swaps so that every couple is sitting side by side.
Couples Holding Hands

N couples sit in 2N seats arranged in a row. You want every couple to sit side by side. Couples are numbered (0,1), (2,3), etc. A swap consists of choosing any two people and having them swap seats. Return the minimum number of swaps so that every couple is sitting side by side.

Example 1:
Input: {"row":[0,2,1,3]}
Output: 1
Input
arr ={"row":[0,2,1,3]}

Row: [0, 2, 1, 3]

Couples on Couch (paired people share color)

0

seat 0

2

seat 1

1

seat 2

3

seat 3

Couple (0, 1)

Couple (2, 3)

Swaps:

0

Variables
No variables to display
DepthFunction Call
Stack empty
0/1