Amazon SDE 2 Bar Raiser Question

Anonymous User
1373
May 05, 2025
May 05, 2025

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!

Comments (5)