Problem of the day
For the first test case, ‘A’ = [5, 6, 4, 10], ‘B’ = [4, 6, 10, 5], here in the ‘B’ we can swap 4 with 10 to form [10, 6, 4, 5] and we can then swap 10 with 5 to form the array [5, 6, 4, 10] which is identical to ‘A’. Hence the answer is 2.
The first input line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case contains a single integer ‘N’ representing the size of both arrays.
The second line of each test case contains ‘N’ space-separated integers representing the ‘A’ array elements.
The third line of each test case contains ‘N’ space-separated integers representing the ‘B’ array elements.
For each test case, print a single integer representing the minimum number of swaps required to make ‘B’ identical to ‘A’
Print a separate line for each test case.
1 ≤ T ≤ 10
1 ≤ N ≤ 1000
0 ≤ A[i], B[i] ≤ 10^9
Time Limit: 1 sec
You do not need to print anything. It has already been taken care of. Just implement the given function.
2
4
5 6 4 10
4 6 10 5
3
1 2 3
1 3 2
2
1
For the first test case, ‘A’ = [5, 6, 4, 10], ‘B’ = [4, 6, 10, 5], here in the ‘B’ we can swap 4 with 10 to form [10, 6, 4, 5] and we can then swap 10 with 5 to form the array [5, 6, 4, 10] which is identical to ‘A’. Hence the answer is 2.
For the second test case, ‘A’ = [1, 2, 3], ‘B’ = [1, 3, 2], here in the second array we can swap 3 with 2 to form [1, 2, 3] which is identical to ‘A’. Hence the answer is 1.
2
5
1 2 3 4 0
0 4 3 2 1
4
1 2 3 4
1 2 3 4
2
0