
Amazon Interview Questions
58 real coding interview questions recently asked at Amazon, spanning Arrays and Strings, Sliding Window and Two Pointers, Trees and Graphs, and 3 more topics, with a real difficulty tag and a direct LeetCode link for every question.
By DevsUnite · 58 Problems
Total Problems: 58Difficulty Levels:EasyMediumHard
Given an array and a target, find the two indices whose values sum to the target, typically solved in a single pass using a hash map that stores each value's complement as it's seen. It requires no advanced technique, which is exactly the point — it's a fast, low-friction warm-up used to confirm a candidate can reach for a hash map instead of defaulting to a brute-force O(n^2) nested loop.
Given a collection of intervals, merge all overlapping ones. The standard approach sorts intervals by start time, then does a single linear pass, extending the current merged interval whenever the next one overlaps and starting a new one otherwise. It's a foundational interval problem that shows up across many companies because interval merging underlies a large family of harder scheduling and calendar-style questions.
Given a list of strings, group the ones that are anagrams of each other. The typical solution hashes each string to a canonical key (either its sorted characters or a fixed-length character-count signature) and groups strings sharing a key in a hash map. It's a straightforward but reliable test of whether a candidate reaches for the right canonicalization strategy and understands the tradeoffs between sorting-based and counting-based keys.
Compute, for each index, the product of all array elements except the one at that index, without using division. The standard O(1)-extra-space solution builds a running prefix product and running suffix product in two passes, multiplying them together for the final answer. It tests array manipulation and space-optimization thinking — specifically whether a candidate can avoid the naive division-based shortcut and still hit optimal time and space.
Find the contiguous subarray with the largest sum, the textbook application of Kadane's algorithm: track the best sum ending at the current index (either extend the previous subarray or start fresh at the current element) alongside a running global maximum. It's one of the most fundamental dynamic-programming-style problems in interviewing, testing whether a candidate has the core DP intuition of 'best solution ending here' down cold.
Rotate an n x n matrix 90 degrees clockwise in place. The common technique is to transpose the matrix (swap elements across the diagonal) and then reverse each row, though a layer-by-layer four-way swap also works. It's a compact test of in-place matrix manipulation and geometric/index reasoning without needing any extra data structure.
Find all unique triplets in an array that sum to zero. The standard approach sorts the array, then for each element uses a two-pointer sweep over the remaining elements, carefully skipping duplicate values to avoid repeated triplets in the output. It extends the simpler two-pointer/two-sum pattern into a triplet setting and tests whether a candidate can handle the deduplication logic correctly, which is where most candidates lose points.
Given an elevation map, compute how much water it can trap after rain — the water trapped at each index equals the shorter of the tallest bars to its left and right, minus its own height. It's solvable with two pointers in O(1) extra space, with a monotonic stack, or with two precomputed max-prefix/max-suffix arrays, making it a great vehicle for comparing multiple valid techniques in one interview. Its breadth of companies asking it reflects that it's one of the most widely used checks of two-pointer/array reasoning in the entire interview circuit.
Convert a non-negative integer into its English words representation (e.g. 1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"). The approach breaks the number into groups of three digits, converts each group using lookup tables for ones/teens/tens and hundreds, then appends the appropriate scale word (thousand, million, billion) per group. It's not algorithmically deep, but it's implementation-heavy with many easy-to-miss edge cases (zero, teens, trailing zero groups), making it a good test of careful, methodical coding under a large but mechanical spec.
Count the number of contiguous subarrays that sum to exactly k. The efficient solution uses a running prefix sum alongside a hash map counting how many times each prefix-sum value has occurred, since a subarray sums to k exactly when the difference between two prefix sums equals k. It's a strong test of the prefix-sum-plus-hash-map pattern, a technique that generalizes to many other subarray-counting problems.
You may choose one contiguous subarray and one integer x, then add x to every element in that subarray exactly once, and must return the maximum possible frequency of a given target value k in the resulting array. The standard technique considers each candidate source value v that could be shifted into k (i.e. x = k - v), transforms the array into a scoring array (+1 where an element equals v, -1 where it already equals k, since shifting it away loses a k), then finds the best-scoring subarray with a Kadane's-style max-subarray-sum scan; the answer is k's original count plus the best score found across all choices of v. It tests whether a candidate can reduce an unfamiliar-sounding operation into a known max-subarray-sum pattern, which is the harder conceptual leap rather than the implementation itself.
Given an integer, you must pick a digit and replace every occurrence of it with another digit twice — once to maximize the resulting number and once to minimize it — then return the difference. Both are greedy digit-replacement problems: for the maximum, replace the first non-9 digit found with 9 everywhere it occurs; for the minimum, if the leading digit isn't already 1, replace all its occurrences with 1, otherwise scan the remaining digits for the first one that is neither 0 nor 1 and replace all its occurrences with 0 (skipping 0 and 1 avoids either a no-op or creating a leading zero). It tests careful case analysis on digit strings rather than any deep algorithm, and the leading-zero edge case is where most mistakes happen.
Given a log of (username, timestamp, website) visits, find the 3-website sequence (in chronological order) that was visited by the largest number of distinct users, breaking ties lexicographically. The approach groups visits by user and sorts each user's visits by timestamp, generates all distinct 3-length subsequences per user, and tallies how many unique users each subsequence appears for across everyone. It tests combining grouping/hashing with combinatorial subsequence generation and precise tie-breaking logic, rather than any single well-known algorithm.
Given a sorted array, find the first and last index of a target value in O(log n) time. The standard solution runs two separate binary searches — one biased to find the leftmost occurrence, one biased to find the rightmost — rather than a single search followed by linear scanning, which would break the required time complexity on arrays with many duplicates. It's a precise test of binary search boundary handling, a skill many candidates get subtly wrong under time pressure.
Given a set of points on a 2D plane, find the maximum number that lie on the same straight line. The typical approach fixes each point as a pivot and computes the slope to every other point, using a hash map keyed by a reduced-fraction (or normalized) slope representation to avoid floating-point precision errors, then takes the largest bucket size across all pivots. It tests geometric reasoning combined with hashing, plus careful handling of vertical lines and duplicate/overlapping points, which are easy to mishandle.
Log in to save your progress, favorites, and notes to your account.
Frequently asked questions
What coding interview questions does Amazon ask?
This page tracks 58 real, recently reported Amazon coding interview questions, organized by topic: Arrays and Strings, Sliding Window and Two Pointers, Trees and Graphs, and 3 more topics.
How many Amazon interview questions are on this list?
58 questions in total: 3 Easy, 36 Medium, and 19 Hard, each linked to its real LeetCode problem page.
Is it free to use?
Yes. Browsing every problem on this page is completely free, with no account required. Creating a free DevsUnite account lets you save your checked-off progress, star favorites, and add personal notes that sync across devices.
Do I need an account to track my progress?
You can read and solve every problem without logging in. An account is only required to mark a problem as done, star it, or add a note. Those actions save to your account instead of resetting on refresh.