Skip to content

Amazon’s software engineering interview is unusual in one respect above all others: every round, without exception, includes behavioral questions on its Leadership Principles. You can solve every coding problem and still be rejected because your stories were thin. At the same time, the technical bar is real. The coding rounds are classic data structures and algorithms at medium-to-hard difficulty, and the design round assumes planetary scale: whatever you build, the follow-up is “how does this work at a million transactions per second?” This chapter prepares you for both halves, with particular attention to the AI and ML infrastructure roles that are a growing share of Amazon’s hiring.

Concepts from other sections (18)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

  • Idempotency: the property that re-running a step does not change its result, which makes pipelines recoverable. Read more: Chapter 1: Foundations in Data Engineering
  • Dynamic programming (DP): solving a problem by breaking it into overlapping subproblems and storing each subproblem’s answer the first time it is computed, which turns an exponential recursion into a polynomial computation. Read more: Chapter 9: Dynamic programming in Programming and Algorithms
  • Two pointers: a technique that walks two indices through an array, from opposite ends or in the same direction, so that each move provably skips only candidates that cannot be the answer; on sorted or monotonic data it turns an O(n2)O(n^2) pair search into an O(n)O(n) sweep. Read more: Chapter 4: Two pointers and sliding window in Programming and Algorithms
  • Sliding window: a contiguous range of an array or string whose two ends move only forward, so each element enters and leaves once and the whole scan is O(n)O(n). Read more: Chapter 4: Two pointers and sliding window in Programming and Algorithms
  • Lowest common ancestor (LCA): the deepest node that has both of two given nodes as descendants, counting a node as its own descendant; found by searching both subtrees in a general binary tree, or by following the values left or right in a BST. Read more: Chapter 7: Trees in Programming and Algorithms
  • Binary search tree (BST): a binary tree in which every node’s value is greater than every value in its left subtree and less than every value in its right subtree, so a search follows one root-to-leaf path and an in-order traversal yields the values in sorted order. Read more: Chapter 7: Trees in Programming and Algorithms
  • Breadth-first search (BFS): traversal in order of hop distance using a FIFO queue. Read more: 18.6 Graph as an adjacency list in Programming and Algorithms
  • Depth-first search (DFS): traversal that follows one path as far as possible before backtracking, using a stack. Read more: 18.6 Graph as an adjacency list in Programming and Algorithms
  • Flood fill: a DFS or BFS from one cell that marks every cell reachable through matching neighbors; starting one from each unvisited cell counts connected regions, such as the islands in a grid. Read more: Chapter 8: Graphs in Programming and Algorithms
  • Patience sorting: an O(nlog⁡n)O(n \log n) method for the longest increasing subsequence that keeps the smallest possible tail for each subsequence length and binary searches where each new value belongs; the number of piles is the length of the subsequence. Read more: Chapter 5: Binary search in Programming and Algorithms
  • Bottom-up DP / tabulation: filling a table of subproblem answers in an order where each entry’s dependencies are already computed, with no recursion; the iterative way to implement dynamic programming. Read more: Chapter 9: Dynamic programming in Programming and Algorithms
  • Edit distance: the minimum number of insertions, deletions, and substitutions that turn one string into another, computed by a two-sequence DP over pairs of prefixes in O(mn)O(mn). Read more: Chapter 9: Dynamic programming in Programming and Algorithms
  • Binary heap: a complete binary tree in an array in which no child comes out before its parent. Read more: 15.6 A binary heap with lazy deletion in Programming and Algorithms
  • Consistent hashing: placing shards and keys on a hash ring so that adding or removing a shard moves only nearby keys. Read more: 3.3 Databricks
  • Write-through / write-back / write-around: write cache and database together / write cache now and database later / write only the database. Read more: Chapter 6: Distributed Data and Caching in Systems Engineering
  • Fan-in / fan-out: the number of inputs feeding one output, and the number of outputs fed by one input. Read more: 13.4 Variance propagation and initialization in Mathematics
  • foundation model: a model pretrained on broad data at scale and then adapted to many downstream tasks. Read more: 5.3 Model landscape and lifecycle in AI Engineering
  • Feature store: a system that computes features once and serves them both online, for inference, and offline, for training. Read more: 1.2 Full-stack AI engineering

The chapter follows the loop. It starts with the process and compensation, then the themes that run through every round, and then spends the most time on the Leadership Principles and the STAR method, because that is where most of your preparation time should go. After that come the coding rounds (with a worked, Amazon-flavored order-routing problem), the services-oriented system design round, the Bar Raiser, and the AI and ML topics specific to AWS. It ends with a preparation plan.

Learning objectives

  • Describe Amazon’s five-to-six-round loop and the role of the Bar Raiser.
  • Prepare 10 to 15 STAR stories that map onto the 16 Leadership Principles, told in the first person with metrics.
  • Recognize the frequently reported coding problem families and solve a practical priority-queue routing problem, including its concurrency pitfall.
  • Design services-oriented systems with sagas, compensation, idempotency, and event-driven messaging, using AWS building blocks.
  • Discuss the AWS AI/ML stack and common ML design questions.

The coding rounds assume fluency with standard data structures and algorithms, and the design round builds on Distributed systems in this book. For AI and ML roles, read ML infrastructure and Full-stack AI engineering too. The saga and compensation patterns used in the design section are developed in depth in Durable Orchestration and Workers in Systems Engineering.

The loop takes two to four weeks and has five or six rounds:

RoundFormatDurationFocus
Recruiter ScreenPhone30 minBackground, role fit, LP preview
Online AssessmentHackerRank/CodeSignal90-120 min2 coding problems + work simulation
Phone ScreenCoding + LP60 min1-2 coding problems + behavioral
Onsite 1Coding + LP60 minDS&A + Leadership Principles
Onsite 2Coding + LP60 minDS&A + Leadership Principles
Onsite 3System Design + LP60 minLarge-scale design + LP
Onsite 4Bar Raiser + LP60 minCross-team assessment + LP deep dive

Notice the last column: every round includes Leadership Principles questions. That is non-negotiable at Amazon.

For a senior SDE (L6) in the US, base salary is $175-190K and is capped. Equity comes as RSUs on a back-loaded schedule, vesting 5%, 15%, 40%, and 40% over four years. To offset the light early vesting, there is a front-loaded sign-on bonus of $50-150K. Total compensation is about $350-450K in the first year and rises to about $400-600K in years three and four as the equity ramps.

Five themes run through the loop. The first dominates: Leadership Principles are evaluated in every round, and you cannot pass without strong stories. The second is that coding is bread and butter: classic data structures and algorithms, at medium-to-hard LeetCode level. The third is that scale is assumed; Amazon operates at planetary scale, so every answer should consider what happens at a million transactions per second. The fourth is Bias for Action: Amazon values shipping over perfection, so show that you can move fast while keeping high standards. And the fifth is that AI and ML are growing. AWS AI services (SageMaker, Bedrock, Titan), Alexa, recommendations, and robotics make ML infrastructure a major hiring area.

This is the most important part of your preparation. Amazon has 16 Leadership Principles, and you need two or three strong stories for each, told in STAR format. Because stories overlap, 10 to 15 well-chosen stories can cover all of them. The principles and the behavior each describes are:

#PrincipleKey Behavior
1Customer ObsessionStart with the customer, work backwards
2OwnershipThink long-term, never say “that’s not my job”
3Invent and SimplifyExpect innovation, find ways to simplify
4Are Right, A LotGood judgment, seek diverse perspectives
5Learn and Be CuriousNever stop learning
6Hire and Develop the BestRaise the bar, develop others
7Insist on the Highest StandardsRelentlessly high standards
8Think BigCreate bold vision, think differently
9Bias for ActionSpeed matters. Calculated risks are okay.
10FrugalityDo more with less
11Earn TrustListen, speak candidly, self-critical
12Dive DeepStay connected to details, audit frequently
13Have Backbone; Disagree and CommitChallenge decisions respectfully, then commit
14Deliver ResultsFocus on inputs, deliver with quality
15Strive to be Earth’s Best EmployerSafe, diverse, empathetic workplace
16Success and Scale Bring Broad ResponsibilityBetter every day, for customers and community

STAR gives each story a shape the interviewer can score:

S - Situation: Set the scene (1-2 sentences)
T - Task: What was YOUR specific responsibility?
A - Action: What did YOU do? (Most time here, be specific)
R - Result: Quantifiable outcome + what you learned

Four Amazon-specific habits make the difference. Say “I,” not “we,” because the interviewer wants your contribution. Include specific metrics: “$2M saved,” “latency reduced 40%,” “99.95% to 99.99%.” Prepare follow-up depth for questions like “What would you do differently?” and “What was the biggest risk?” And map each story to two or three principles, since interviewers assign credit by principle and a single story can earn it for several.

The most frequently reported questions cluster around five principles. For Customer Obsession: “Tell me about a time you went above and beyond for a customer,” and “Describe a time you had to balance customer needs with technical constraints.” For Ownership: “Tell me about a time you took ownership of something outside your role,” and “Describe a project where you saw it through end to end, including the parts you didn’t enjoy.” For Dive Deep: “Tell me about a time you had to dig into data to find the root cause of a problem,” and “Describe a time metrics told you one thing but reality was different.” For Have Backbone; Disagree and Commit: “Tell me about a time you disagreed with a decision and what you did,” and “Describe a time you had to commit to a plan you didn’t fully agree with.” And for Bias for Action: “Tell me about a time you made a decision with incomplete information,” and “Describe a time you took a calculated risk.”

There are two or three coding rounds. Each 60-minute round typically has one or two problems in about 45 minutes, with the remaining 15 reserved for Leadership Principles questions. The problems are standard data structures and algorithms (arrays, trees, graphs, dynamic programming, hash maps), solved on a whiteboard or in a shared editor, and clean code is expected: name variables well and handle edge cases.

The reported problems fall into five families, each with a characteristic technique:

FamilyProblemTechnique
Arrays and stringsTwo Sum / Three SumHash map, two pointers
Longest Substring Without Repeating CharactersSliding window
Group AnagramsSorted string as hash key
Product of Array Except SelfPrefix and suffix products
TreesLowest Common AncestorRecursion or parent pointers
Serialize/Deserialize BSTPreorder traversal
Validate BSTInorder traversal or min/max bounds
Level Order TraversalBFS with a queue
GraphsNumber of IslandsDFS/BFS flood fill
Course ScheduleTopological sort
Shortest PathBFS (unweighted), Dijkstra (weighted)
Clone GraphBFS/DFS with a hash map
Dynamic programmingLongest Increasing SubsequenceO(nlog⁡n)O(n \log n) with patience sorting
Coin ChangeBottom-up DP
Edit Distance2D DP
Word BreakDP with a hash set
Amazon favoritesLRU CacheDoubly linked list plus hash map
Design a Parking LotObject-oriented design
Merge IntervalsSort by start, merge overlaps
Min StackStack with min tracking

A worked problem: routing orders to warehouses

Section titled “A worked problem: routing orders to warehouses”

Amazon also asks practical problems in its own domain. A representative one: route each incoming order to a warehouse that has the inventory to fulfill it, and let each warehouse process its orders in priority order, with Prime ahead of expedited ahead of standard.

The design follows from the requirements. Each warehouse gets its own priority queue, a binary heap keyed by (priority, timestamp), so higher-priority orders come first and ties go to the earlier order. Submitting an order scans the warehouses for one whose stock covers every item, counting duplicates, and pushes the order onto that warehouse’s heap. Processing pops the highest-priority order and decrements the inventory.

import heapq
from collections import defaultdict
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional
class Priority(Enum):
PRIME = 0
EXPEDITED = 1
STANDARD = 2
@dataclass(order=True)
class Order:
priority: int
timestamp: float
order_id: str = field(compare=False)
items: list = field(compare=False)
warehouse: str = field(compare=False, default="")
class OrderRouter:
"""Route orders to nearest warehouse with available inventory."""
def __init__(self):
self.queues: dict[str, list] = defaultdict(list) # warehouse -> priority queue
self.inventory: dict[str, dict[str, int]] = {} # warehouse -> {item: count}
def add_warehouse(self, warehouse_id: str, inventory: dict[str, int]):
self.inventory[warehouse_id] = inventory
self.queues[warehouse_id] = []
def submit_order(self, order: Order) -> Optional[str]:
"""Route order to a warehouse that can fulfill it. Returns warehouse ID."""
for warehouse_id, stock in self.inventory.items():
if self._can_fulfill(stock, order.items):
order.warehouse = warehouse_id
heapq.heappush(self.queues[warehouse_id],
(order.priority, order.timestamp, order))
return warehouse_id
return None # No warehouse can fulfill
def process_next(self, warehouse_id: str) -> Optional[Order]:
"""Process highest-priority order from a warehouse."""
queue = self.queues[warehouse_id]
if not queue:
return None
_, _, order = heapq.heappop(queue)
# Decrement inventory
stock = self.inventory[warehouse_id]
for item in order.items:
stock[item] -= 1
return order
def _can_fulfill(self, stock: dict[str, int], items: list[str]) -> bool:
needed = defaultdict(int)
for item in items:
needed[item] += 1
return all(stock.get(item, 0) >= count for item, count in needed.items())

_can_fulfill counts each item’s required quantity before comparing with stock, so an order for two of the same item is checked correctly. Submission is O(W⋅k)O(W \cdot k) for WW warehouses and kk items in the order, plus O(log⁡n)O(\log n) for the heap push; processing is O(log⁡n+k)O(\log n + k). Despite the docstring, the scan picks the first warehouse that can fulfill the order rather than the nearest, which is a natural follow-up: add a distance to each warehouse and scan in distance order.

Warning: Inventory is checked at submission but decremented only at processing. Two orders submitted back to back can both pass the check against the same last unit, and the second will drive stock negative. A correct design reserves inventory at submission (decrement or hold it immediately) and releases the reservation if the order is cancelled. Pointing this out unprompted is exactly the kind of ownership the interviewers look for.

Amazon’s system design round is grounded in its services-oriented architecture. Four principles shape a good answer. Build services, not monoliths: everything is a service with a well-defined API. Work backwards from the customer, starting with the customer experience. Assume two-pizza teams: each service is owned by a small, autonomous team. And address operational excellence: how do you monitor, alarm, and run on-call for this?

The most Amazon-flavored prompt is the order system itself. An order service coordinates inventory, payment, and fulfillment services, each owning its own store:

[Client] --> [API Gateway] --> [Order Service]
|
+---------------+---------------+
| | |
[Inventory Svc] [Payment Svc] [Fulfillment Svc]
| | |
[DynamoDB] [Payment Gateway] [Warehouse Svc]
|
[Shipping Svc]

Because no single database spans these services, an order is a saga: a distributed transaction carried out as a sequence of local steps, from order to payment to inventory to fulfillment. Each step needs a compensation: if payment fails after inventory has been reserved, release the inventory. Every API call must be idempotent, so retries are safe. And services communicate asynchronously through events, using SQS and SNS.

For “Design Amazon’s recommendation system,” the building blocks are user-item collaborative filtering, which at Amazon scale means matrix factorization or alternating least squares; “customers who bought X also bought Y,” built from co-purchase frequency and item-item similarity; real-time personalization that combines batch-computed embeddings with real-time session features; and A/B testing through Weblab, Amazon’s experimentation platform.

For “Design a distributed cache” (think ElastiCache), cover consistent hashing for key distribution; write-through versus write-behind strategies; cache invalidation by TTL, by events, or with versioned keys; and hot-key mitigation through local caching, key splitting, and request coalescing.

For “Design AWS Lambda,” cover cold-start optimization with pre-warmed containers and snapshot-and-restore; concurrency control with per-function and account-level limits; event-source integration with SQS, Kinesis, and API Gateway triggers; and resource allocation, where CPU scales with the memory configuration.

Using Amazon’s own services naturally in your designs shows that you understand the ecosystem. These are the ones to know:

ServicePurposeWhen to Reference
DynamoDBNoSQL key-value storeHigh-throughput, low-latency reads/writes
SQSMessage queueAsync decoupling between services
SNSPub/sub notificationFan-out to multiple consumers
KinesisReal-time streamingEvent processing, analytics
S3Object storageLarge files, data lake
SageMakerML platformTraining, hosting, MLOps
BedrockManaged LLM serviceAI application development
ECS/EKSContainer orchestrationMicroservice deployment
CloudWatchMonitoringMetrics, logs, alarms

The difference between SQS (a queue, where each message goes to one consumer) and SNS (pub-sub, where each message fans out to every subscriber) is worth being precise about; Messaging and Distributed Queueing in Systems Engineering explains it, along with long-polling.

The Bar Raiser is an interviewer from a different team who holds veto power over the hire. Their job is to make sure every hire raises the bar. Expect the deepest Leadership Principles probing of the whole loop, possibly with a coding or design component as well. The question they are answering is whether you are better than half of the current Amazonians at your level, and their follow-up questions go three or four levels deep on each story.

Prepare for that by saving your best stories for this round. Expect “Tell me more” and “Why?” repeatedly. Have backup examples, because if they exhaust one story they will ask for another. And be ready to discuss failures and what you learned from them, which speaks to Earn Trust and Learn and Be Curious.

For AI-focused roles, know the AWS AI/ML stack. SageMaker is the end-to-end ML platform: notebooks, training, hosting, and pipelines. Bedrock provides managed foundation models, including Claude, Titan, and Llama. Titan is Amazon’s own family of foundation models. Inferentia and Trainium are Amazon’s custom AI chips, an alternative to NVIDIA GPUs. And Comprehend, Rekognition, and Textract are pre-built AI services.

Common ML design questions include designing a fraud detection system, a product search ranking system, an ML feature store, and a model monitoring and retraining pipeline. ML infrastructure covers the patterns behind each.

Write your Leadership Principles stories first and spend about 60% of your preparation time on them, aiming for 10 to 15 strong stories that each map to several principles. Work 100 to 150 LeetCode problems, focusing on Amazon-tagged ones. Use Amazon’s own services in your designs, referencing DynamoDB, SQS, and Kinesis naturally. Think like an owner: in every answer, show end-to-end thinking about how you would run the thing in production. Practice STAR out loud, recording yourself and keeping each answer to three or four minutes. Read about Amazon’s tenets, since each team has them and understanding the tenet-driven culture shows depth. And always cover operational excellence (monitoring, alerting, runbooks, on-call) in any system design.

  • Leadership Principles (LPs): Amazon’s 16 cultural principles, assessed in every interview round.
  • STAR: Situation, Task, Action, Result; the structure for a behavioral story.
  • Bar Raiser: an interviewer from outside the hiring team, with veto power, who ensures each hire raises the bar.
  • Saga: a distributed transaction carried out as a sequence of local steps, each with a compensating action.
  • Compensation: the action that undoes a completed saga step when a later step fails.
  • Weblab: Amazon’s internal A/B testing platform.
  • Every round tests the Leadership Principles; 10 to 15 metric-rich, first-person STAR stories mapped to several principles each are the core of your preparation.
  • Coding is classic medium-to-hard data structures and algorithms in about 45 minutes per round, plus practical problems like order routing.
  • In the order router, reserve inventory at submission, not at processing, or concurrent orders can oversell.
  • System design is services-oriented: sagas with compensation, idempotent APIs, SQS/SNS events, and operational excellence, built from AWS services.
  • The Bar Raiser probes your best stories three or four levels deep and can veto the hire.
  1. Why does a story told with “we” score poorly at Amazon even if the project was a success?
    AnswerInterviewers assign Leadership Principles credit for your individual actions. "We" hides what you specifically did, so there is nothing to credit; the Action part of STAR should be in the first person and specific.
  2. In the OrderRouter, two orders each needing the last unit of an item are submitted before either is processed. What happens, and how would you fix it?
    AnswerBoth pass _can_fulfill because stock is decremented only in process_next, so the second processed order drives stock to −1. Reserve inventory at submission time (decrement immediately or record a hold) and release it if the order is cancelled.
  3. In an order saga, payment fails after inventory was reserved. What must happen, and what property must every step have to make retries safe?
    AnswerA compensating action releases the reserved inventory. Every service call must be idempotent, so retrying a step after a timeout does not reserve or charge twice.
  4. When would you choose SNS over SQS in a design?
    AnswerWhen several independent services must each react to the same event (fan-out). SQS delivers each message to one consumer, which suits distributing work across a pool; the common pattern is SNS fanning out to one SQS queue per consuming service.
  5. What does the Bar Raiser assess that the other interviewers might not?
    AnswerWhether you are better than half of current Amazonians at the level, judged by someone outside the hiring team with no stake in filling the role. They probe stories several levels deep and can veto the hire.
  6. Why does Amazon front-load the sign-on bonus?
    AnswerRSUs vest 5/15/40/40 over four years, so equity income is small in the first two years. The sign-on bonus offsets that gap.