We are given an array of integers 1 <= a[i] <= 20, of size N (1<= N <= 10 ^ 5) and we have to group similar elements together. In one operation we can swap two adjacent elements. Find the minimum no of swaps.
Input — 1 2 1 2 1 Output — 3
Input — 1 3 3 2 Output — 0
Input — 1 3 2 1 2 3 Output — 4
Explanation of test case 3 — swap a[2] with a[3] swap a[4] with a[3] swap a[4] with a[5] swap a[2] with a[3] The array becomes — { 1, 1, 2, 2, 3, 3}