Amazon OA question

Result
Ongoing
Posted
28 Sept 2025
472 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.

How it went

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.

Questions asked (1)

  1. 01

    Minimize Swaps for File Size-Virus Affinity Mismatch

    Data Structures & Algorithms · Hard

    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$$

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Amazon recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

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