Company: Amazon_25july
Difficulty: medium
Minimum Swaps to Satisfy File Affinities Problem Description Modern software systems face frequent cyber attacks. To harden its systems against them, a security team runs checks against n files, where the i th file has size fileSize[i] , alongside n known viruses. The i th virus targets the i th file and only succeeds against a file whose size equals affinity[i] . To cut down the potential damage, the team can rearrange the files. In one operation, the team picks two files, i and j , and swaps their sizes, i.e., fileSize[i] and fileSize[j] . Given the file sizes and the viruses' target sizes, find the fewest operations needed so that fileSize[i] == affinity[i] holds for every file from 1 to n . If no number of operations can achieve this, return -1. Function Description Complete the function calculateMinimumSwaps in the editor below. calculateMinimumSwaps has the following parameters: int fileSize[n] : the file sizes int affinity[n] : the affinities Returns int : the minimum number of