OA Question Min swaps to make good array
Anonymous User
426

An array is called good if A[2i] = A[2i + 1]. Given an array A of size N, find the minimum number of adjacent swaps required to make it good.
Constraints :
1 <= N <= 2000
1 <= A[i] <= 10^5

Eg : A = [1,2,2,1] (2 swaps for [1,1,2,2])

Comments (2)