시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 64 MB | 88 | 34 | 32 | 58.182% |
You have two arrays A and B, each contains numbers 1, 2, ... , N, though not necessarily in this order.
In each operation, you can swap any two numbers in A.
Your task is to determine the least number of operations needed to transform A to B.
Output the minimum number of operations needed to transform A to B.
4 1 4 2 3 4 3 1 2
3
7 3 6 4 7 1 2 5 4 3 7 6 1 5 2
4
Sample Input 1
The 3 swap operations to transform [1,4,2,3] into [4,3,1,2] are:
Sample Input 2
The 4 swap operations to transform [3,6,4,7,1,2,5] into [4,3,7,6,1,5,2] are: