Amazon| SDE2 | Onsite Loop Interview
Anonymous User
2681

Round1 - Low Level Design
LP

  1. Tell me about a time when you went above and beyond to serve customer. Why? How?
  2. Tell me about a time when you took an unpopular stance and your team members or manager disagreed. What? how navigate?
    Design Tic Tac Toe

Round 2 - Hiring Manager - System Design
LP

  1. Tell me about a time when you had to learn new skillset beyond the scope of your day to day work
  2. Conflict Resolution with manager
    Design Instagram

Round 3 - Coding
LP

  1. Customer obsession
  2. Dive deep

Medium question, didnt come across in leetcode but could be solved using priority queue in under 20 mins

Round 4 - Coding
LP

  1. Deliver under strict deadlines
  2. Tell me about a time when you had to make a decision between long-term value or short-term results.

Design a lottery system where a customer can buy a lottery ticket ranging from 1 cent to 100 dollars. At the end of sale of all lottery ticket we will have a lucky draw where a winner will be chosen randomly and the chances of winning a customer should be according to the price they have paid for the ticket in other words the one who paid more should have more chances of winning.

Interviewer had a certain solution in mind, struggled a lot to arrive at that, came up with something similar, not sure if this helped

import java.util.*;

class LotterySystem {
    private final NavigableMap<Integer, String> ticketMap;
    private final Random random;
    private int totalWeight;

    public LotterySystem() {
        this.ticketMap = new TreeMap<>();
        this.random = new Random();
        this.totalWeight = 0;
    }

    public void buyTicket(String customer, int amount) {
        if (amount < 1 || amount > 10000) {
            throw new IllegalArgumentException("Ticket price must be between 1 cent and 100 dollars");
        }
        totalWeight += amount;
        ticketMap.put(totalWeight, customer);
    }

    public String drawWinner() {
        if (ticketMap.isEmpty()) {
            throw new IllegalStateException("No tickets sold, cannot draw a winner");
        }
        int luckyNumber = random.nextInt(totalWeight) + 1;
        return ticketMap.ceilingEntry(luckyNumber).getValue();
    }

    public static void main(String[] args) {
        LotterySystem lottery = new LotterySystem();
        lottery.buyTicket("Alice", 500); // Alice buys a ticket worth $5.00
        lottery.buyTicket("Bob", 1000); // Bob buys a ticket worth $10.00
        lottery.buyTicket("Charlie", 200); // Charlie buys a ticket worth $2.00
        
        System.out.println("The winner is: " + lottery.drawWinner());
    }
}

Spent nearly half an hour in LP principle for each round. Its okay to repeat stories if the questions repeat. All the best!

Verdict: Accepted

Compensation Details -
https://leetcode.com/discuss/compensation/6389764/Amazon-London-SDE2

Comments (10)