Amazon Coding Interview Questions
23 Amazon coding interview problems with full optimal solutions — 2 easy, 18 medium, 3 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Amazon interviewer values, and a FAQ section.
Showing 23 problems of 23
- #1easyfoundational
1. Two Sum
Given an array of integers and a target, return the indices of the two numbers that add up to the target. Amazon asks this to test whether you can articulate the space-for-time tradeoff before reaching for the optimal hash-map solution.
- #20easyfoundational
20. Valid Parentheses
Given a string of brackets, return true if every opener has a matching, correctly-nested closer. Amazon asks this as a warm-up to test whether you reach for a stack and articulate the LIFO invariant.
- #42hardfrequently asked
42. Trapping Rain Water
Given heights, compute water trapped after rain. Amazon asks this to test whether you reach for the two-pointer invariant 'water at i = min(maxLeft, maxRight) - height[i]' and can articulate why two-pointer beats prefix-max arrays on space.
- #49mediumfrequently asked
49. Group Anagrams
Given a list of strings, group anagrams together. Amazon asks this to test whether you reach for the 'sorted-string as key' or 'frequency-tuple as key' pattern to avoid pairwise anagram-checking.
- #56mediumfrequently asked
56. Merge Intervals
Given a list of intervals, merge all overlapping intervals. Amazon asks this to test whether you reach for the sort-then-sweep pattern that's O(n log n).
- #127hardfrequently asked
127. Word Ladder
Find the length of the shortest transformation from beginWord to endWord, changing one letter at a time. Amazon asks this to test whether you reach for BFS on an implicit graph and articulate the shortest-path-on-unweighted-edges insight.
- #138mediumfrequently asked
138. Copy List With Random Pointer
Deep-copy a linked list with both next and random pointers. Amazon asks this to test the hash-map clone pattern and (for senior IC) the O(1)-space interleave trick.
- #146mediumfrequently asked
146. LRU Cache
Design a cache that evicts the least recently used key when full. Amazon asks this to test whether you can combine a doubly-linked list (for O(1) reorder) with a hash map (for O(1) lookup).
- #200mediumfoundational
200. Number of Islands
Given a 2D grid of '1's and '0's, count the number of islands. Amazon asks this to test whether you reach for DFS/BFS flood-fill and articulate why each cell is visited at most once for O(m*n).
- #208mediumfrequently asked
208. Implement Trie (Prefix Tree)
Implement a Trie with insert, search, and startsWith operations. Amazon asks this to test whether you can implement the canonical multi-way tree data structure with the 'children map + isEnd flag' pattern.
- #210mediumfrequently asked
210. Course Schedule II
Given courses and prerequisites, return a valid course order or empty if impossible. Amazon asks this to test whether you can extend the cycle-detection from Course Schedule I to producing the topological order via Kahn's BFS.
- #211mediumfrequently asked
211. Design Add and Search Words Data Structure
Implement a dictionary supporting addWord and search where '.' is a wildcard. Amazon asks this to test whether you reach for a trie and can handle the wildcard via DFS over all children.
- #230mediumfrequently asked
230. Kth Smallest Element in a BST
Given a BST and integer k, return the k-th smallest element. Amazon asks this to test whether you reach for inorder traversal (which visits BST nodes in sorted order) and can short-circuit early.
- #340mediumfrequently asked
340. Longest Substring with At Most K Distinct Characters
Given a string, return the length of the longest substring with at most k distinct characters. Amazon asks this to test whether you reach for sliding window with a char-frequency map.
- #347mediumfrequently asked
347. Top K Frequent Elements
Given an array of numbers and integer k, return the k most frequent elements. Amazon asks this to test whether you reach for bucket sort or heap and can articulate the n log k vs O(n) tradeoff.
- #621mediumfrequently asked
621. Task Scheduler
Given a list of tasks and cooldown n, return the minimum time to finish all tasks where the same task can't run within n steps of itself. Amazon asks this to test whether you reach for the greedy 'fill slots from most-frequent task' formula.
- #692mediumfrequently asked
692. Top K Frequent Words
Given an array of strings and integer k, return the k most frequent words sorted by frequency (descending) then lexicographically (ascending). Amazon asks this to test whether you handle the dual-key sort cleanly in a heap or a comparator.
- #763mediumfrequently asked
763. Partition Labels
Partition a string into as many parts as possible so that each letter appears in at most one part. Amazon asks this to test whether you reach for the greedy 'extend partition until furthest end' pattern.
- #767mediumfrequently asked
767. Reorganize String
Given a string, rearrange so no two adjacent chars are the same, or return empty if impossible. Amazon asks this to test whether you reach for a max-heap of (count, char) and articulate the 'highest-count first' greedy.
- #937mediumcompany favorite
937. Reorder Data in Log Files
Sort log lines so letter-logs come before digit-logs, letter-logs are sorted by content (with identifier as tiebreaker), and digit-logs preserve original order. Amazon asks this to test whether you can implement a stable, multi-key comparator without bugs.
- #973mediumfrequently asked
973. K Closest Points to Origin
Given an array of points and integer k, return the k points closest to the origin (0, 0). Amazon asks this to test whether you reach for a max-heap of size k or quickselect — same pattern as top-K problems.
- #994mediumfrequently asked
994. Rotting Oranges
Given a grid of oranges (empty / fresh / rotten), return the minimum minutes until all fresh oranges rot, or -1 if impossible. Amazon asks this to test whether you reach for multi-source BFS — starting from ALL rotten oranges simultaneously.
- #1192hardfrequently asked
1192. Critical Connections in a Network
Find all critical connections (bridges) in an undirected graph. Amazon asks this to test whether you know Tarjan's bridge-finding algorithm and can articulate the discovery-time / low-link invariant.
Related interview-prep guides
HireVue Tech Interview Guide: The 2026 Playbook for Async Video Rounds
HireVue is the category-leading async video interview platform. Candidates record answers solo, on the clock, and a combined AI-plus-human review layer scores the recording days later. For 2026 tech jobseekers, the format is different enough from live interviews to need its own playbook. This guide is that playbook.
HackerRank Tech Interview Guide 2026: What It Tests, How It Tracks You, and the Modern Setup
HackerRank is still the volume leader in first-round technical screens for 2026 tech hiring. A browser-sandboxed coding environment that logs every keystroke, paste event, and tab-focus change inside its own tab. This guide covers what it tests, the boundary of what it can and cannot detect, and how a modern desktop setup pairs with a HackerRank session without leaking into the screen-share.
CodeSignal GCA for Tech Interviews in 2026: The Complete Guide
The CodeSignal General Coding Assessment is a 70-minute, four-task timed test scored on a 600 to 850 scale, used as a filter by Goldman Sachs, Capital One, Robinhood, Brex, and a growing list of tech and finance employers. This guide breaks down what it tests, how it scores, what it tracks during your session, and how a modern desktop setup pairs with it without showing up in proctored recordings.