New update is available. Click here to update.

Posted: 26 Mar, 2021

Difficulty: Hard

```
List = [3, 0, 2, 1]
We have to make ‘0’ adjacent to ‘1’ and ‘2’ to ‘3’. And, to achieve this we can swap ‘0’ with ‘2’.
New list = [3, 2, 0, 1].
Therefore, the answer (minimum number of swaps) is equal to 1.
```

```
There will be only distinct numbers present in the given list.
```

```
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a single integer ‘N’ such that the size of the list is 2 * ‘N’.
The second line of each test case will contain 2 * ‘N’ integers separated by a single space that represents the elements/numbers present in the list initially.
```

```
For each test case, print the minimum number of swaps possible to make every even number ‘E’ adjacent to (‘E’ + 1).
Output for every test case will be printed in a separate line.
```

```
You don’t need to print anything; It has already been taken care of. Just implement the given function.
```

```
1 <= T <= 10
1 <= N <= 100
0 <= ARR[ i ] < 2 * N
Time limit: 1 sec
```

SIMILAR PROBLEMS

Best time to buy and sell stock II

Posted: 5 Sep, 2022

Difficulty: Moderate

JUMP GAME

Posted: 8 Sep, 2022

Difficulty: Moderate

COUNT ISLANDS

Posted: 14 Sep, 2022

Difficulty: Moderate

Split String

Posted: 14 Sep, 2022

Difficulty: Easy

Ninja And The Class Room

Posted: 19 Sep, 2022

Difficulty: Easy

Categories:

Popular Courses: