20 Amazon SDE Interview Questions

Amazon's SDE loop mixes data structures, design and Leadership Principles in every round. Twenty questions from squizzu's bank, five playable right here.

11 min read

Amazon SDE interview questions come in two kinds, and the loop asks both in nearly every round. The first is a coding or design problem. The second is a Leadership Principles question: "tell me about a time you disagreed with your manager", "tell me about a time you shipped with incomplete data". Candidates who prepare only the first kind are surprised by how much of each hour goes to the second.

The technical half of the Amazon SDE interview is narrower than it looks. Amazon's coding rounds return again and again to a handful of patterns: hash maps over arrays, breadth-first search on a grid, a structure that keeps keys ordered, a heap for "top K", intervals. SDE II candidates add a design round that is almost always about a service doing slow work reliably.

The 20 questions below come from the Data Structures and System Design sets in squizzu's question bank, picked for those patterns. Five are playable right here. Answer before you read the explanation; recognising a pattern and applying it under a timer are different skills, and the timer is the one you will meet.

Try 5 of them right now

No sign-up, no email. Each question shows the reasoning and an in-depth breakdown of why the wrong options fail, which is usually where the interviewer's follow-up is aimed.

Squizzu Logo
Data Structures • Array Techniques: Two Pointers, Sliding Window, Prefix Sums & Intervals

Question 1 / 5

Using a running prefix sum with a hash map of earlier prefix counts (a sliding window fails because of the negative numbers), how many contiguous subarrays of a = [3, 4, -7, 1, 3, 3, 1, -4] sum to k = 7?

a = [3, 4, -7, 1, 3, 3, 1, -4]
k = 7

Two of those five are computed rather than recalled: you have to run the prefix sum or the BFS to get the number, which is exactly what an Amazon coding round asks you to do on a shared editor. The space-complexity question is the one people lose points on after writing a correct solution.

The other 15 questions

Grouped roughly the way the rounds move: arrays and complexity, then trees, then graphs, then heaps, tries and union-find, and finally one design question about ordering events. Treat them as a checklist. If you cannot name the structure, its cost and its failure case within a minute, add it to your revision list.

  1. A calendar service receives an unsorted list of booked time intervals and must merge all overlapping ones into the smallest set of disjoint intervals. What is the first step that makes a single linear sweep possible?Data Structures • Array Techniques: Two Pointers, Sliding Window, Prefix Sums & Intervals
  2. To save memory, a team changes their dynamic array so that a full array grows by a fixed 1000 slots instead of doubling. They then append n items one at a time, with n in the millions. Counting element copies during resizes, what is the amortized cost per append?Data Structures • Complexity Analysis & Amortized Cost
  3. A public web service parses request bodies into chained hash maps using a fixed hash function whose algorithm is publicly known. An attacker sends thousands of keys that all hash to one bucket, so each insert walks a long chain and the CPU saturates. Which change removes the attacker's ability to precompute such keys?Data Structures • Hash Tables, Sets & Maps
  4. Consider a binary tree with nodes labelled 1 to 10. Node 1 has children 2 and 3. Node 2 has children 4 and 5. Node 4 has children 6 and 7. Node 6 has a left child 8. Node 5 has a right child 9. Node 9 has a right child 10. Node 3 is a leaf. Height counts edges on the longest root-to-leaf path, and diameter counts edges on the longest path between any two nodes. What does the snippet below print?Data Structures • Binary Trees & Traversals
  5. The keys 10, 20, 30, 40, 50, 25 are inserted in that order into an initially empty AVL tree, with rotations rebalancing the tree after each insert. What is the pre-order listing (root, then left subtree, then right subtree) of the final tree?Data Structures • Binary Search Trees & Self-Balancing Trees
  6. A map app models towns as vertices and roads as unweighted edges, where every road counts as one hop. It must find the fewest hops from a start town to every other town. Which traversal should it use?Data Structures • Graph Representation & Traversal
  7. A maze solver models a grid as a graph with V cells and E moves. Walking into an open cell costs 0 and breaking through a wall costs 1, so every edge weight is 0 or 1. You want the cheapest path from the start cell to every other cell in O(V + E) time. Which approach fits?Data Structures • Graph Algorithms: Shortest Paths, MST & Topological Sort
  8. How does Prim's algorithm build a minimum spanning tree of a connected weighted undirected graph?Data Structures • Graph Algorithms: Shortest Paths, MST & Topological Sort
  9. Why does bottom-up heap construction (sift down every internal node, from the last one to the root) take O(n) rather than O(n log n)?Data Structures • Heaps & Priority Queues
  10. What exact array does the snippet below print after a heapify, a push of 0 and two pops on a min-heap built with the standard library?Data Structures • Heaps & Priority Queues
  11. A service keeps one million words and must answer two kinds of query: "is this exact word stored" and "does any stored word start with this prefix". A teammate proposes a hash set of the words for both. What is the main problem with the hash set for the prefix query?Data Structures • Tries
  12. A search box stores product names in a trie. When a user types a prefix, the app must list every stored name that starts with it. After the app walks down the trie along the typed prefix, what does it do next to build the list?Data Structures • Tries
  13. Union-find with union by size and no path compression: in each union the root of the smaller tree becomes a child of the other root, and on equal sizes either root may be chosen. Over every possible sequence of unions on 20 elements that ends with a single tree, what is the greatest possible height of that tree, counted as edges on the longest root-to-leaf path?Data Structures • Union-Find (Disjoint Set Union)
  14. The function below checks bracket balance and also records the deepest nesting it saw. What does the call at the bottom of the snippet return?Data Structures • Stacks, Queues & Deques
  15. A shipment-tracking service applies status events (picked up, in transit, delivered) that must be applied in order per shipment; different shipments are independent. Peak load is 2,000 events per second across a million shipments, one consumer instance handles about 300 per second, and the log-based broker guarantees order only within a partition. How should events be assigned to partitions?System Design • Messaging, Queues & Event Streaming

The five answers, written out

Counting subarrays that sum to k, with negative numbers

Short answer: 4. Keep a running prefix sum and a hash map counting how often each prefix value has appeared. At every index, add the count of earlier prefixes equal to prefix - k.

Explanation: A sliding window works when all numbers are positive, because growing the window only increases the sum and shrinking it only decreases it. One negative value breaks that, and this array has two. The prefix-sum method does not care about signs: a subarray from i+1 to j sums to k exactly when prefix[j] - prefix[i] = k. The prefixes here are 0, 3, 7, 0, 1, 4, 7, 8, 4. Prefix 7 at index 2 matches the starting 0; prefix 7 at index 6 matches both earlier zeros; prefix 8 at index 7 matches the 1. That is four subarrays, in O(n) time and O(n) space.

What the interviewer is testing: Whether you check the precondition of the pattern you reach for. Sliding window is the reflex; the negative numbers are there to see if you notice.

Common follow-up: "Return the longest such subarray instead of the count." (Store the first index at which each prefix appears instead of a count.)

What is the space complexity of a recursive sum?

Short answer: O(n), because n stack frames are alive at the deepest point of the recursion.

Explanation: Each call waits for the next one to return before it can add its element, so the calls stack up until the base case. Passing an index instead of slicing the list avoids O(n²) copying, but it does not remove the frames. Stack frames are auxiliary space even though no data structure is allocated. In Python the default recursion limit of about 1,000 frames turns this into a crash on a long list; in Java a deep enough input throws StackOverflowError.

What the interviewer is testing: Whether your complexity analysis counts the call stack. Candidates often say "O(1) space, I didn't allocate anything", and the interviewer marks it down.

Common follow-up: "Rewrite it iteratively, or tell me whether tail-call optimisation would help in the language you are using." (Neither Python nor Java performs it.)

Finding the earliest booking at or after time t

Short answer: A balanced binary search tree with a ceiling lookup, in O(log n) per query and per insert or delete.

Explanation: The query needs order: "smallest key greater than or equal to t". A hash map has no order, so it can only scan every key. A sorted array answers with binary search but costs O(n) per insert, which hurts when bookings change all day. A balanced BST keeps keys ordered and stays O(log n) for all three operations. In Java that is TreeMap.ceilingKey; in C++ std::set::lower_bound; Python has no built-in balanced tree, so candidates use bisect on a sorted list and explain the insert cost, or the sortedcontainers package if allowed.

What the interviewer is testing: Whether you choose the structure from the operations it must support. Saying "hash map" by default is the trap.

Common follow-up: "Now find all bookings that overlap a given interval." (Interval trees, or two ordered maps, with a discussion of the cost.)

How long until the fire reaches the last grass cell?

Short answer: 8 minutes, found with a multi-source breadth-first search starting from both fires at once.

Explanation: Put every fire cell into the queue at distance 0, then expand level by level, marking each grass cell with the minute it catches. Running a separate BFS from each fire and taking the minimum per cell gives the same answer at several times the cost. The last cell to catch, at row 4 and column 4, is reached at minute 8, and every grass cell is reachable. The general pattern, simultaneous spread from several sources on a grid, is one of the most frequently reported shapes in Amazon coding rounds, usually in the form of rotting oranges, spreading infection or distance to the nearest gate.

What the interviewer is testing: That you recognise BFS as the shortest-path algorithm for unweighted grids and know to seed it with all sources. Also that you handle the unreachable case and return a sentinel rather than looping forever.

Common follow-up: "Some cells take two minutes to burn instead of one." (The graph is now weighted, so use 0-1 BFS or Dijkstra.)

A slow upload job inside an HTTP request

Short answer: Store the upload, enqueue a transcode job, return a job ID immediately, and let a pool of workers process the queue.

Explanation: A 20-minute job cannot live inside a request with a 2-second budget on servers that can disappear at any time. A durable queue separates accepting the work from doing it. The client polls a status endpoint or receives a notification when the job finishes. Workers scale independently of the web tier, and a job whose worker dies becomes visible again and is retried. On AWS the usual building blocks are S3 for the upload, SQS for the queue and a fleet of workers on ECS or EC2; S3 event notifications can enqueue the job directly.

What the interviewer is testing: The basic SDE II design move: separate slow work from the request path, then reason about what happens when each component fails. Expect the next ten minutes to be about retries and duplicate processing.

Common follow-up: "The worker finished the transcode but crashed before deleting the message. What happens, and how do you make that safe?"

What the Amazon SDE loop actually tests

  • Online assessment. Usually two coding problems in roughly 90 minutes, plus a work-style section that maps your preferences to the Leadership Principles. Some candidates also get a work simulation with scenario questions.
  • Phone screen. Not always present. When it is, one coding problem in a shared editor, plus Leadership Principles questions.
  • Final loop. About four interviews of an hour each. Most combine one technical problem with two or three Leadership Principles. SDE I loops tend to include object-oriented design; SDE II loops add system design.
  • Bar Raiser. One interviewer, from outside the hiring team, whose job is to keep the hiring bar consistent across Amazon. Their vote carries extra weight.

Amazon Leadership Principles interview questions

Roughly half of the Amazon interview questions you hear in a loop are behavioural. Amazon publishes 16 Leadership Principles, and each loop interviewer is assigned a few to probe. Every question starts with "tell me about a time when..." and continues with follow-ups that drill into your own actions until the interviewer is sure the story is yours.

The principles that come up most in SDE loops, with the way the question is usually phrased:

  • Customer Obsession. "Tell me about a time you changed a technical decision because of what customers needed."
  • Ownership. "Tell me about something you fixed that was not your job."
  • Dive Deep. "Tell me about a problem you solved only after digging several levels below the obvious cause."
  • Bias for Action. "Tell me about a decision you made without all the data you wanted."
  • Have Backbone; Disagree and Commit. "Tell me about a time you disagreed with your manager or team."
  • Deliver Results. "Tell me about a deadline you were at risk of missing."
  • Earn Trust. "Tell me about a mistake you made and how you handled it."

Answer in STAR form (situation, task, action, result), say "I" rather than "we", and end with a number. Prepare at least two stories per principle. One loop can ask about the same principle twice, and reusing a story across interviewers gets noticed in the debrief.

"Tell me about a time you made a decision without all the data you wanted"

Short answer: Pick a story where waiting had a real cost, you acted on what you knew, and you limited the risk of being wrong.

Explanation: This is the Bias for Action question. A strong answer has four parts. First, the situation and the cost of waiting: a release blocked, customers affected, a deadline. Next, what you knew and what you did not know. Then the decision and, most importantly, how you made it reversible or contained: a feature flag, a canary rollout to 5% of traffic, a rollback plan you tested beforehand. Last, the measured result. The skeleton fits in two minutes: "Checkout errors rose to 2% after a dependency upgrade, and the root cause would take days to find. I rolled back the upgrade behind a flag within an hour, kept the investigation running, and re-enabled it a week later with the fix. Error rate returned to 0.1% the same day."

What the interviewer is testing: Whether you can tell a reversible decision from an irreversible one. Amazon's own phrase for this is "two-way doors": decisions you can undo should be made quickly. A story where you acted fast on something irreversible, and got lucky, scores worse than one where you acted fast because you had made it safe.

Common follow-up: "What would you have done if the rollback had failed?"

"Tell me about a time you disagreed with your team"

Short answer: Show that you argued with data, accepted the outcome, and then worked to make the decision succeed, even if it was not yours.

Explanation: This tests Have Backbone; Disagree and Commit. The trap is a story where you were right all along and everyone else came round. That shows backbone, not commitment. The stronger story has you lose the argument, or reach a compromise, and then commit fully: "I argued for a relational database because our queries needed joins, with a benchmark showing a 4x latency difference. The team chose DynamoDB for operational reasons. I designed the access patterns and the denormalised tables myself, and we shipped two weeks early."

What the interviewer is testing: Both halves of the principle. Disagreeing respectfully with evidence, and then not undermining a decision you argued against.

Common follow-up: "Looking back, who was right?" (Answer honestly. If the decision turned out well, say what you learned about the trade-off you had underweighted.)

How to answer an Amazon coding question out loud

Interviewers score the conversation, not only the code. Five beats work for almost every problem:

  1. Restate and ask. Input sizes, value ranges, whether numbers can be negative, what to return when nothing matches. The prefix-sum question above is decided by one of those answers.
  2. Give the brute force and its cost. Then say why it is not good enough.
  3. Name the pattern. "This is a multi-source BFS", "this needs ordered keys". Naming it shows you are choosing, not guessing.
  4. Write it, then test it by hand. Walk a small example through the code, including an edge case.
  5. State time and space, including the call stack and the hash map.

What to do next

Fifteen questions remain, and the useful way to meet them is the one you just used: pick an answer before any explanation is on screen.

Answer the remaining 15 in quiz mode on squizzu. Each one has an explanation and an in-depth breakdown, and the rest of the Data Structures set is there to keep going.

For the design round, system design interview questions for 2026 covers estimation, queues, sharding and consistency with its own self-check. Comparing loops? 20 Google AI/ML interview questions and 20 Meta data scientist interview questions follow the same format for those companies, and so does 20 Microsoft software engineer interview questions.

Frequently asked questions

What is the Amazon SDE interview process?

Typically an online assessment with two coding problems and a work-style section, sometimes a technical phone screen, then a final loop of about four one-hour interviews held on the same day. Most loop interviews combine a coding or design problem with Leadership Principles questions, and one interviewer is a Bar Raiser from outside the hiring team who can veto the hire. Candidates usually describe the process as taking three to six weeks.

What coding topics does Amazon ask most?

Arrays and strings with hash maps, two pointers and sliding windows; trees and graph traversal, especially BFS on grids; heaps for top-K and scheduling problems; and intervals. Dynamic programming appears but less often than at some other large companies. The difficulty is usually medium, and interviewers care about a clear explanation of complexity and edge cases as much as a passing solution.

How important are Amazon Leadership Principles in the SDE interview?

Very. Amazon has 16 Leadership Principles, and most loop interviewers are assigned two or three of them to assess with behavioural questions, usually for 15 to 25 minutes of a one-hour interview. A strong coding performance with weak Leadership Principles answers is a common reason for rejection. Prepare several detailed stories from your own work in STAR form, each with a measurable result.

Does Amazon ask system design for SDE I?

Usually not full distributed system design. SDE I loops tend to include object-oriented design instead, such as designing a parking lot or a library system with classes and interfaces. SDE II and above get a system design round where you design a service end to end, discuss data storage, scaling and failure handling, and often reference AWS building blocks.

What programming language should I use for the Amazon interview?

Any mainstream language you are fluent in. Java and Python are the most common choices. Pick the one where you can write a hash map, a queue, a heap and a sorted structure without looking anything up, because those four cover most Amazon coding problems.

How do I prepare for the Amazon online assessment?

Practise timed medium problems on arrays, hash maps, graphs and heaps, and get used to writing code that handles edge cases without a debugger. The assessment also includes a work-style section that maps your preferences to the Leadership Principles, so read the principles before you start it.

We use cookies

Some cookies are needed to run this site. With your consent we also measure how it is used, so that we can improve it.

Cookie policy

Choose what we may measure. You can change this at any time.

Strictly necessary

Essential for the proper functioning of the website. These cannot be disabled.

Performance and analytics

Help us understand how Squizzu is used, diagnose technical issues and improve the service.

20 Amazon SDE Interview Questions | Squizzu