Amazon SDE 2 Bar Raiser Question

amazon logo
amazon
SDE 2India
May 5, 20252 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.

Full Experience

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!

Interview Questions (1)

Q1
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.

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!