Top 15 Amazon Coding Interview Problems, Ranked by Frequency

June 6, 202611 min read
interview-prepcareerdsaalgorithms
TL;DR
  • Amazon's pool is 60% medium; phone screens skew easy-to-medium, onsites add harder problems at SDE-2 and above
  • Two Sum (LC 1) is the single most-reported problem — the test is reaching for a hash map unprompted, not just solving it
  • Amazon layers every problem: after your solution, expect a follow-up pivot (cooldown, million-QPS constraint, or a harder data structure on top)
  • Multi-source BFS (Rotting Oranges) catches most candidates who default to single-source traversal and get wrong answers
  • Four patterns cover all 15: sliding window with a hash map, BFS (single and multi-source), heap for K-element problems, and converging two pointers
  • Communication is scored separately from correctness; a correct solution explained in silence still produces a low score on Amazon's rubric

You have 45 minutes. You are on camera. The interviewer just asked you Two Sum.

That's the Amazon coding interview experience in three sentences. Not because Amazon's engineers are lazy, but because these problems are signal-dense: they reveal whether you instinctively reach for the right data structure or whether you think nested loops are a personality trait.

Here are the 15 problems that show up most in Amazon rounds, ranked by frequency, with what Amazon is actually watching for when they ask each one.

How Amazon's Pool Actually Works

Phone screens are almost entirely mediums. Onsite rounds mix medium and hard, with harder problems more common at SDE-2 and above.

Amazon also layers. An interviewer will present a clean array problem, watch you solve it, then say: "Now what if we need to run this a million times a second?" That pivot is their equivalent of "and one more thing." It usually means a heap, a different traversal, or a hash map optimization on top. Knowing the base solution gets you in the door. Understanding why the extension works is what separates the hires.

Every round also carries Leadership Principles questions. Sometimes 15 minutes, sometimes enough to feel like a separate interview. Budget for it.

The 15 Amazon Coding Interview Problems

#ProblemLC #DifficultyCore Pattern
1Two Sum1EasyHash Map
2Best Time to Buy and Sell Stock121EasyState Tracking
3Longest Substring Without Repeating Characters3MediumSliding Window
4Merge Intervals56MediumSort + Greedy
5Product of Array Except Self238MediumPrefix / Suffix
6Number of Islands200MediumBFS / DFS
7Rotting Oranges994MediumMulti-source BFS
8Reorganize String767MediumMax-Heap + Greedy
9Top K Frequent Elements347MediumHeap
10Reverse Linked List206EasyTwo Pointers
11Lowest Common Ancestor of a Binary Tree236MediumDFS Post-Order
12LRU Cache146MediumHash Map + Doubly Linked List
13Trapping Rain Water42HardTwo Pointers
14Word Ladder127HardBFS
15Serialize and Deserialize Binary Tree297HardBFS / DFS + Encoding

1. Two Sum (LC 1)

The most-reported problem in Amazon's entire interview history. If you've been in tech for more than 10 minutes, you have seen this problem. You might have this problem tattooed somewhere.

The test is not whether you can solve it. It's whether you immediately reach for a hash map or waste time on nested loops. Amazon wants to see the space-for-time trade without being prompted. The follow-up is almost always: "What if the array is sorted?" Know both. Coming in with only the O(n) hash map version and stalling on the follow-up is a real thing that costs people real offers.

2. Best Time to Buy and Sell Stock (LC 121)

One pass, two variables: running minimum price and running maximum profit. O(n) time, O(1) space. Simple in the way that most useful things are.

Amazon frequently extends this mid-interview: add a cooldown period, allow multiple transactions, or introduce a transaction fee. The base solution is a screen. The extensions reveal whether you understand the state machine underneath, or whether you memorized a solution you don't actually own.

3. Longest Substring Without Repeating Characters (LC 3)

Sliding window with a character frequency map. Left boundary advances when a duplicate enters.

This tests whether you know the sliding window template cold enough to adapt under pressure. Know the O(n) hash map version, not the fixed-size character array shortcut that silently breaks on Unicode inputs. Amazon has global users. They notice when your solution assumes ASCII.

4. Merge Intervals (LC 56)

Sort by start time, walk the array, extend or emit. The critical detail: when two intervals overlap, the merged end is max(current_end, next_end), not just next_end. Miss that and edge cases break quietly and you won't know until the interviewer raises an eyebrow.

Amazon asks this because interval problems map directly to scheduling and resource allocation systems Amazon operates at scale. Expect an insert-interval follow-up or a minimum-meeting-rooms variant. They have a lot of meetings to schedule.

5. Product of Array Except Self (LC 238)

Two passes: left-products prefix, then right-products suffix.

Amazon specifically wants the O(1) extra space version, which builds the output array in-place using a running right-product variable instead of a separate suffix array. The space constraint is part of the test, not a bonus. Mention it before they ask. Waiting for them to say "can you do it in O(1) space?" is table stakes that you should take off the table yourself.

6. Number of Islands (LC 200)

BFS or DFS from each unvisited land cell, marking visited cells as water. This is the kind of problem where everyone knows the answer and you still have to actually write it cleanly.

This is Amazon's most frequently reported graph problem, and it almost always gets extended: 3D grid, largest island, or dynamic island additions. Know both BFS and DFS cold. The union-find version shows up at senior levels. Pick a traversal and be able to switch.

7. Rotting Oranges (LC 994)

Multi-source BFS: seed the queue with every rotten orange simultaneously, then expand level by level. The name alone makes this problem memorable, which is probably why Amazon likes it.

The canonical mistake is single-source BFS or DFS, which gives wrong answers when multiple rot sources exist at time zero. Amazon uses this to test whether you recognize when multi-source initialization is required versus when standard traversal applies. It's a one-line change in setup and a complete difference in correctness.

8. Reorganize String (LC 767)

Build a max-heap of character frequencies. Each step: pull the two most frequent characters, append them in order, decrement counts, re-add.

This is Amazon's signature heap-layering problem: an array task that becomes efficient only when you overlay a priority queue. Greedy without the heap fails when the most frequent character has a large lead. Think of this as the problem that separates "I know what a heap is" from "I know when to reach for one."

9. Top K Frequent Elements (LC 347)

Count frequencies with a hash map, then maintain a min-heap of size K.

The target complexity is O(n log k), not O(n log n). Amazon cares because k is often orders of magnitude smaller than n at their data volumes. Know the bucket sort O(n) approach as a follow-up. Mentioning it unprompted before the interviewer asks is the kind of move that gets written into the feedback form with a positive adjective.

10. Reverse Linked List (LC 206)

Three pointers: prev, curr, next. Walk the list once, flipping each link.

This is a fluency screen, not a real problem. If you hesitate or need to diagram your way through it out loud, the interview shifts. Not because reversal is hard, but because an interviewer who watches you struggle with the simplest linked list operation will wonder what happens when the list gets complicated. Know both iterative (O(1) space) and recursive versions. This one should take two minutes.

11. Lowest Common Ancestor of a Binary Tree (LC 236)

Post-order DFS: return the node if it matches p or q. If both subtrees return non-null, the current node is the LCA.

Amazon is checking why post-order works here, not just that you can produce a working implementation. Be ready to explain why this algorithm breaks on a general graph. "Because cycles" is the start of an answer, not the whole one.

12. LRU Cache (LC 146)

Hash map for O(1) get and put, doubly linked list for O(1) eviction order.

Sentinel head and tail nodes eliminate null-check edge cases entirely and are the difference between a clean implementation and a bug-prone one. Amazon asks this because LRU caches appear throughout their infrastructure. It's not academic. Expect a follow-up on why a singly linked list does not support O(1) removal from an arbitrary position.

For a full implementation walkthrough, see the LRU cache implementation guide.

13. Trapping Rain Water (LC 42)

Two pointers from opposite ends.

When the left max is smaller than the right max, the left side is the bottleneck, and you can compute trapped water there without knowing the exact right max. That insight collapses an O(n) space prefix/suffix DP solution into O(1) with two pointers. Amazon often starts you at the DP version and pushes you further. This is one of those problems where arriving at the optimal solution mid-interview, out loud, is more impressive than having memorized it.

14. Word Ladder (LC 127)

BFS where each word is a node and edges connect words differing by exactly one character. Conceptually simple. Implementation is where people get themselves in trouble.

The key implementation question is how you enumerate neighbors efficiently: generating all one-letter mutations is O(26 * L) per node, which is the expected approach. Bidirectional BFS cuts the search space in half. Worth mentioning at SDE-2 before the interviewer asks. Not because it's required, but because it tells them you're thinking about scale.

15. Serialize and Deserialize Binary Tree (LC 297)

Level-order BFS with null markers, or pre-order DFS with a delimiter. Both work. Pick one and be consistent.

Amazon asks this at SDE-2 and senior levels because it combines tree traversal mastery with protocol design: you define an encoding, handle edge cases, and write a decoder that inverts it exactly. The common follow-up: how would you handle trees with billions of nodes? That's a distributed serialization question. Have a direction ready, even if the full answer would take a whiteboard and two engineers.

The Four Patterns Behind All 15

You can cover most of these by drilling four patterns until they're automatic:

  1. Sliding window with a hash map. LC 3, and any problem asking for the longest or shortest subarray satisfying a constraint.
  2. BFS: single-source and multi-source. LC 200, 994, 127. Multi-source initialization is the version most candidates miss cold.
  3. Heap for K-element problems. LC 347, 767. The shift from O(n log n) sorting to O(n log k) with a bounded heap is the optimization Amazon rewards.
  4. Two-pointer converging from opposite ends. LC 42, 206. Know the condition that moves each pointer and why.

The pattern is more transferable than any specific solution. Amazon interviewers extend problems mid-session. Candidates who internalized patterns adapt. Candidates who memorized solutions freeze on the first modification, and that freeze shows up in the feedback.

For broader coverage, the top 50 LeetCode medium problems guide maps the full landscape.

How to Practice These

Don't grind them in order. Pick one, solve it without hints on a blank screen, then explain your reasoning out loud from scratch as if you're in a real interview. That last step is the one most candidates skip because it feels awkward and produces no green checkmarks. It is also the only step that matters once you're in the room.

Amazon's rubric scores communication as a separate dimension from correctness. A correct solution explained in silence still produces a low score. Amazon isn't just hiring someone who can write code. They're hiring someone who can talk to other humans about code, in a company that takes written and verbal communication seriously enough to put it in their Leadership Principles.

SpaceComplexity runs AI voice mock interviews with rubric-based scoring across all four dimensions. If you want to practice explaining your approach under timed pressure, it's built for exactly that.

Every Amazon round also includes Leadership Principles questions. For prep on all 16 LPs with STAR frameworks, the Amazon behavioral interview questions guide covers the full picture. For a complete breakdown of what gets scored in each round, the Amazon software engineer interview guide walks through the format.

Further Reading