amazon logo
Amazon· SDE 2

Amazon SDE 2 Bar Raiser Question

Location
India
Posted
5 May 2025
284 reads

Summary

I experienced an Amazon SDE 2 Bar Raiser interview in India, where I was presented with a problem to design a lottery system for Amazon customers with weighted chances, and extract the top K winners. My approach involved using a segment tree, prefix sum, and binary search.

How it went

Level: L4 Location: India

Question: You are designing a lottery system for Amazon. All customers who placed orders between 1 usd to 100 usd are automatically part of this lottery system. A person who paid 10 usd should have more chances of winning than a person who paid 1 usd. Given a list of customers, the amount they paid return the top K winners. Not that winners can be duplicate in the list.

At first look, it looked like a classic Top-K problem to me. Except that this is a lottery system and not a leaderboard problem. Everybody has a fair chance of winning. Winner selection is random sampling.

My approach is to use segment tree + prefix sum + binary search. Closest problem I could think of was - Random Pick With Weight problem on LeetCode.

LMK what you think!

Questions asked (1)

  1. 01

    Lottery System: Weighted Random Pick Top K Winners

    Data Structures & Algorithms

    You are designing a lottery system for Amazon. All customers who placed orders between 1 usd to 100 usd are automatically part of this lottery system. A person who paid 10 usd should have more chances of winning than a person who paid 1 usd. Given a list of customers, the amount they paid return the top K winners. Not that winners can be duplicate in the list.

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!