Amazon coding interviews tend to mix classic data structures and algorithms with problems that feel closer to production work. You should expect graph traversal, dynamic programming, cache design, string handling, and the occasional systems-flavored coding task where correctness and tradeoff awareness both matter.
Below are 20 Amazon coding questions that get a lot of attention from candidates. They cover the kinds of patterns that come up often, and they give a good picture of what Amazon asks across technical screens, take-home projects, and onsite rounds.
Graphs, dependencies, and reachability
Find Affected Services After Shutdown
This is the kind of graph question Amazon likes because it maps well to service dependencies and failure impact. Interviewers are checking whether you can model directed relationships cleanly, reason about propagation, and handle edge cases like disconnected components or repeated dependencies.Find a valid dependency order
This is a topological sort problem in business clothing. The main test is whether you quickly recognize the DAG pattern, choose Kahn's algorithm or DFS-based ordering, and account for cycles instead of assuming the input is always valid.Check if adding edge creates cycle in digraph
Amazon asks questions like this to see if you can move past memorized full-graph cycle checks and answer a more targeted update question. A strong answer starts from reachability, because adding an edge creates a cycle only if a path already exists in the opposite direction.Solve two set and graph problems
This kind of paired onsite question checks how fast you can identify the right structure, set, map, BFS, DFS, or union-find, without wasting time on brute force. Interviewers also watch whether you communicate your assumptions before coding.Find shortest transformation steps in a word graph
This is a shortest-path problem on an implicit graph, usually solved with BFS. Amazon likes it because it tests whether you can generate neighbors efficiently, avoid repeated work, and keep the solution within reasonable time for large dictionaries.
Web crawlers and systems-flavored coding
Build a BFS Web Crawler
This question mixes traversal with practical constraints. Interviewers want to see whether you can build a queue-driven crawl, deduplicate URLs, respect domain or depth boundaries, and talk through what changes if the crawler becomes distributed.Implement a high-throughput web crawler safely
Compared with the simpler crawler prompt, this one pushes on concurrency and safety. It tests thread-safe deduplication, work scheduling, backpressure, rate limiting, and whether you notice that raw throughput is useless if the crawler races, repeats work, or overwhelms targets.
Strings and dynamic programming
Solve two string DP/hash problems
Amazon often uses compact string questions to check pattern recognition under time pressure. The mention of DP and hashing is a clue that brute-force substring scanning probably will not pass, and you should think about state definition, memoization, or rolling hash tradeoffs.Solve Two String Problems
Easy string rounds are rarely about syntax. They are usually about clean pointer logic, frequency counting, and whether you can avoid hidden quadratic work in operations like repeated slicing or concatenation.Maximize weighted subsequence pairs with wildcards
This take-home prompt is a good example of Amazon using strings to test optimization thinking. The wildcard twist usually means a greedy choice can fail, so interviewers are looking for state-based reasoning and a way to count subsequence contributions without enumerating everything.Return all valid word-break sentences
This is harder than the basic "can segment or not" version because you need all valid outputs. It tests recursion with memoization, pruning, and whether you understand the difference between checking feasibility and generating every valid decomposition.
Arrays, intervals, and optimization
Maximize protected population with one-step guard shifts
This kind of problem checks whether you can convert a story into an optimization model and avoid trying every move blindly. A good start is to compute the effect of each possible shift locally, then reason about the best net gain.Compute minimal operations and optimal server pairing
This paired take-home question is typical of Amazon's easier project work, simple on the surface, but full of opportunities to miss invariants. Interviewers are testing whether you can derive the right greedy or sorting-based insight instead of simulating operations one step at a time.Implement K-means and solve interval/frequency tasks
The interval and frequency pieces check standard coding range, sorting, heaps, maps, and sweep lines. The K-means part checks whether you can implement an iterative algorithm carefully, keep the math and bookkeeping straight, and explain convergence or stopping conditions.Solve Two Array Optimization Problems
Hard array problems at Amazon often come down to choosing the right precomputation, prefix/suffix structure, heap, or binary search over the answer. The interviewer is usually looking for whether you can cut a large search space into something structured and provably correct.Maximize memory capacity with primary-backup servers
This is an optimization problem with a pairing or assignment flavor, which is common in Amazon take-homes. You need to identify the constraint that really drives the answer, then sort or match in a way that maximizes usable capacity without breaking the primary-backup rule.
Core implementation questions
Implement LRU cache with O(1) ops
This is a standard onsite question for a reason. It tests whether you know the hash map plus doubly linked list design, and whether you can implement pointer updates without bugs and explain why each operation stays O(1).Implement integer division without using division
Interviewers ask this to see how comfortable you are with bit manipulation, overflow handling, and sign logic. The usual path is repeated doubling or bit shifts, but the real test is whether you cover cases like minimum integer values and truncation rules.
Assessment-style mixed rounds
- Solve Algorithmic Challenges in Online Coding Assessments This reflects the reality of Amazon screens, where you may get a mixed set rather than one deep problem. The skill being tested is speed with pattern matching. Can you spot whether a problem wants prefix sums, greedy choice, sliding window, BFS, or DP before the clock becomes the main enemy?
ML-oriented coding and implementation depth
- Implement decoder-only GPT-style transformer This is the kind of onsite question you might see for ML-heavy roles, and it is more about engineering clarity than reciting model buzzwords. Interviewers want to know if you understand embeddings, masked self-attention, residual paths, tensor shapes, and how the forward pass fits together in code.
A useful way to prepare for Amazon is to practice by pattern, not by company label alone. If you can recognize graph reachability, topological ordering, BFS on implicit states, DP over strings, cache design, and greedy pairing problems quickly, you will be in much better shape than someone who has only memorized a few famous LeetCode answers.
If you want a broader set to work through, PracHub has 165+ Amazon coding questions, including these popular ones and many more reported by candidates.
Top comments (0)