For this Question: Given two arrays of size N which have the same values but in different orders, we need to make a second array the same as a first array using a minimum number of swaps.

Note:- It is guaranteed that the elements of the array are uniqueFirst line of input contains the size of array N, second line of input contains N space separated integers depicting values of first array, third line of input contains N space separated integers depicting values of second array.

Constraints:-
1 < = N < = 10000
1 < = Arr[i] < = 1000000000Print the minimum number of swaps required to make the second array equal to first.Sample Input:-
5
1 2 3 4 5
3 1 2 5 4

Sample Output:-
3

Sample Input:-
4
3 6 4 8
4 6 8 3

Sample Output:-
2, I have written this Solution Code: 
#include <bits/stdc++.h>
using namespace std;
#define int long long int

// Function returns the minimum number of swaps
// required to sort the array
// This method is taken from below post
// https://www.geeksforgeeks.org/minimum-number-swaps-required-sort-array/
int minSwapsToSort(int arr[], int n)
{
	// Create an array of pairs where first
	// element is array element and second element
	// is position of first element
	pair<int, int> arrPos[n];
	for (int i = 0; i < n; i++)
	{
		arrPos[i].first = arr[i];
		arrPos[i].second = i;
	}

	// Sort the array by array element values to
	// get right position of every element as second
	// element of pair.
	sort(arrPos, arrPos + n);

	// To keep track of visited elements. Initialize
	// all elements as not visited or false.
	vector<bool> vis(n, false);

	// Initialize result
	int ans = 0;

	// Traverse array elements
	for (int i = 0; i < n; i++)
	{
		// already swapped and corrected or
		// already present at correct pos
		if (vis[i] || arrPos[i].second == i)
			continue;

		// find out the number of node in
		// this cycle and add in ans
		int cycle_size = 0;
		int j = i;
		while (!vis[j])
		{
			vis[j] = 1;

			// move to next node
			j = arrPos[j].second;
			cycle_size++;
		}

		// Update answer by adding current cycle.
		ans += (cycle_size - 1);
	}

	// Return result
	return ans;
}

// method returns minimum number of swap to make
// array B same as array A
int minSwapToMakeArraySame(int a[], int b[], int n)
{
	// map to store position of elements in array B
	// we basically store element to index mapping.
	map<int, int> mp;
	for (int i = 0; i < n; i++)
		mp[b[i]] = i;

	// now we're storing position of array A elements
	// in array B.
	for (int i = 0; i < n; i++)
		b[i] = mp[a[i]];

	/* We can uncomment this section to print modified
	b array
	for (int i = 0; i < N; i++)
		cout << b[i] << " ";
	cout << endl; */

	// returing minimum swap for sorting in modified
	// array B as final answer
	return minSwapsToSort(b, n);
}

// Driver code to test above methods
signed main()
{
     
     int n;
cin>>n;
int a[n];
int b[n];
for(int i=0;i<n;i++){
cin>>a[i];}
for(int i=0;i<n;i++){
    cin>>b[i];
}

	cout << minSwapToMakeArraySame(a, b, n);
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?