← Amazon Interview Insights

Amazon·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Apr 2026

Summary

Amazon SWE interview with a scheduling/simulation problem that looks like a simple greedy but has some tricky edge cases around the two-day constraint. Not much context on how it went overall.

Questions Asked (1)

Q1

You have N distribution centers (numbered 1 to N) and a list of M orders where each order specifies a destination city. Each day, a center can work on at most one destination city. If a center's number matches the destination city's number, it can fulfill all remaining orders for that city in one day. If they don't match, the center takes two consecutive days and is blocked during both. Find the minimum number of days to deliver all orders.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Stared at this for a while before I even understood what 'two consecutive days' meant for scheduling.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem constraints and edge cases, then model it as a scheduling problem where each center can process at most one city per day, with processing time 1 if center matches city else 2. The goal is to minimize makespan, which can be solved by greedy assignment or binary search on days with feasibility check.

Pro tip: Demonstrate Amazon's leadership principles by discussing trade-offs between optimality and simplicity, and by proactively considering scalability for large N and M.

1. Clarify the problem

Ask questions to confirm assumptions: Can a center work on multiple orders for the same city in one day? Are orders for the same city independent? Is preemption allowed? What are the constraints on N and M?

2. Model the problem

Represent each city's orders as a job with processing time 1 if assigned to its matching center, else 2. Each center is a machine that can process at most one job at a time. Minimize makespan.

3. Identify the core challenge

The difficulty is assigning cities to centers to balance load and minimize the maximum completion time, considering that mismatched assignments take longer.

4. Propose an algorithm

Use binary search on the answer D (days). For a given D, check feasibility: each center can handle at most D days of work, where a matching city takes 1 day and a non-matching takes 2. Greedily assign cities to centers, prioritizing matching centers.

5. Analyze complexity and edge cases

Discuss time complexity (e.g., O((N+M) log M)) and handle edge cases like more cities than centers, or all orders for one city.

Key Points to Mention

  • Greedy assignment: assign each city to its matching center if possible to save days.
  • Binary search on the minimum days and feasibility check using capacity constraints.
  • Load balancing: distribute cities across centers to avoid bottlenecks.
  • Time complexity analysis and potential optimizations.
  • Edge cases: N=1, M=0, cities with no matching center, multiple orders per city.
  • Trade-offs between optimal solution and simpler heuristics.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.