Amazon Software Engineer Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Compute minimum passes to collect numbers
Question You are given an array shelf of n distinct integers that is a permutation of 1…n. Starting with target = 1, you repeatedly scan shelf from le...
Compute minimum passes over permutation
Question You are given an array shelf representing a permutation of the integers 1..n. Starting with target = 1, you repeatedly scan the array left-to...
Find most frequent log user
Question You are given a list of log entries in string format, where each entry contains a username and an access timestamp separated by a delimiter (...
Solve sliding-window and heap problems
Question Design an algorithm using a sliding window to compute the maximum sum of any contiguous subarray of length k; explain time- and space-complex...
Compute maximum distinct-product pickup days
Question Given an array of positive integers representing quantities of different products, on day i (starting from 1) you must pick exactly i distinc...
Find largest island area
Question Given a 2D grid of 0s and 1s, find the largest area of a connected group of 1s (island) using 4-directional adjacency; return that area. (Var...
Minimize cost & recommend movies
Question Given arrays size[] and cost[] where size[i] is the size of the i-th product and cost[i] is the cost to increase size[i] by one unit, compute...
Implement basic calculator
Question LeetCode 227. Basic Calculator II – implement an arithmetic expression evaluator supporting +, -, *, / and integer operands https://leetcode....
Solve LeetCode string and list problems
Question LeetCode 767. Reorganize String LeetCode 23. Merge k Sorted Lists LeetCode 138. Copy List with Random Pointer https://leetcode.com/problems/r...
Determine Rounds for Star Substring Threshold
Question Given a string S, an offset array O (replacement order), and an integer M, repeatedly replace S[O[i]] with ''. Determine the minimum number o...
Solve array and list algorithms
Question LeetCode 315. Count of Smaller Numbers After Self LeetCode 23. Merge k Sorted Lists Design algorithm for Amazon Locker getPackage (retrieve p...
Solve Rotting Oranges and Bus Walk Reachability
Question LeetCode 994. Rotting Oranges. 2) Given start and end grid coordinates, an integer k (maximum walking distance), and a bidirectional graph of...
Check path in N-ary tree
Given the root of an N-ary tree and a sequence of integers path[0..k-1], determine whether there exists a path starting at the root whose node values ...
Find longest common contiguous subarray
Given two integer arrays A and B, find the length of the longest contiguous subarray that appears in both arrays. If multiple exist, return any one pa...
Implement DFS and tree algorithms
Part 1 (DFS on graph): Given an undirected graph with n nodes labeled 0..n-1 and an edge list, implement a function that returns all connected compone...
Compute reachability and minimal-time same-type scheduling
1) Given four integers a, b, c, d (1 <= a, b, c, d <= 1000), you may perform the following operations any number of times and in any order: (a, b) -> ...
Compute rightmost-smaller delay times
Given an integer array priorities, define delay[i] as the distance to the rightmost index j > i such that priorities[j] < priorities[i]; if no such in...
Find minimum days to deliver all orders
You manage N delivery centers labeled 1..N and an array orderCityList where each element is the destination city of one order (city IDs are in 1..N). ...
Find longest segment with endpoints > interior
Given an integer array nums, find the length of the longest contiguous segment [i..j] (j−i+1 ≥ 2) such that both endpoints are strictly greater than e...
Determine max remainders and anagram after deletions
Part 1 (Array Remainders): Given an integer array A of length n with A[i] > 0. You may choose any integer array B of length n. Define C[i] = B[i] mod ...