Amazon OA question

amazon logo
amazon
Ongoing
September 28, 202513 reads

Summary

I participated in an Amazon Online Assessment where I was presented with an algorithmic problem focused on array manipulation and minimizing swaps to ensure a specific non-matching condition between file sizes and virus affinities.

Full Experience

My recent experience with the Amazon Online Assessment involved tackling a distinct algorithmic challenge. The problem statement was quite clear, detailing a scenario with file sizes and virus affinities, and asked me to determine the minimum swaps necessary to prevent any file from matching its virus's affinity. I found it to be a thought-provoking problem that likely required an understanding of graph theory or advanced array manipulation techniques.

Interview Questions (1)

Q1
Minimize Swaps for File Size-Virus Affinity Mismatch
Data Structures & AlgorithmsHard

Given an array fileSize of n file sizes and an array affinity of n virus affinities (each virus targets a file with a specific size), find the minimum number of operations required so that for every file i, fileSize[i] != affinity[i]. Each operation consists of swapping the sizes of two files. If it is impossible to achieve this condition, return -1.

$$1<=n<10^5$$
$$1<=affinity[i], fileSize[i] < 10^9$$

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!