Company: Amazon_29sep
Difficulty: medium
Calculate Minimum Swaps Problem Description To prevent virus attacks from succeeding, the security team at Amazon runs tests against n files, where the i -th file has size fileSize[i] , and there are n viruses. The i -th virus attacks the i -th file and is only effective against a file whose size is exactly affinity[i] . To minimize the damage, the team performs operations. In one operation, the team chooses two files i and j and swaps their sizes, that is, fileSize[i] and fileSize[j] exchange values. The affinity array never changes. Find the minimum number of operations needed so that fileSize[i] != affinity[i] holds for every file i . If this cannot be achieved after any number of operations, return -1 . Complete the function calculateMinimumSwaps(fileSize, affinity) , which returns that minimum number of operations, or -1 . Input Format Read from standard input. n fileSize[0] fileSize[1] ... fileSize[n-1] n affinity[0] affinity[1] ... affinity[n-1] Line 1 contains the integer n , t