Leave your Email to get the latest Amazon interview questions weekly.
We'll never share your email with anyone else.
No spam we promise.
Given a list of molecules, return the distance between the closest pair...
Given a list of products, and a product priority sequence, return the length of the shortest product sublist that satisfies the priority sequence...
Given a list of file names in a system, write a program to rename the duplicate files...
Given an undirected graph, find out all the vertices when removed will make the graph disconnected...
Given a list of products, and a product priority sequence, check if the input satisfies the priority sequence...
Given an M * N matrix, where matrix[i][j] is the height of the block on position (i, j). Each block has 4 neighbors - the blocks at its top, bottom, left and right. A sink area is a group of neighboring blocks that are fully surrounded by other blocks with greater heights. When water is poured onto the matrix, the sink area traps the water in it. Build a function that finds the number of blocks in the maximum sink area...
Find a pair of entries from two lists that yield a sum that is as close to a target number as possible, without exceeding it...
Given a string str and an integer k, you need to rearrange the string in a way that the same characters must be at least k distance away. If not possible, return "".
str = "aabb", k = 2
You can return either "abab" or "baba".
Given a BST, and an integer k, cut the BST vertically into two substrees A and B, where all nodes in A <= k and all nodes in B > k.
Contrain: for any node A and it’s parent B in the original BST. If after the cut they are both in the same subtree. B should still be the parent of A.
Given a binary tree and a list of nodes say [n1, n2, .. nk], write a program to find the least common ancestor.
You are given a huge number of IPs in a list. Remove all duplicated addresses from the list.
Two people from different teams will work together on a project that requires a total of T hours. Each team is represented as an N-ary tree where a tree node is a team member and the number of hour(s) the member can devote to the project. Find out all the unique combinations of hours that both people's work [t1, t2] add up to T hours...
Input: a list of filenames with paths You need to complete the following class to support linux find command.
You are on a flight and want to watch two movies during this flight. You need to pick two movies and the total duration of the two movies is less than or equal to d.
Given k days and array P as the item sizes, find out the minimum total container size required to move all the items...
Given a 2D grid, each cell is either a zombie or a human. Zombies can turn adjacent (up/down/left/right) human beings into zombies every day. Find out how many days does it take to infect all humans?
A queue of people are waiting to buy ice cream from you.
Each person buys one ice cream, which sells for $5.
Each customer is holding a bill of $5, $10 or $20.
Your initial balance is 0.
Find whether you will be able to make change for every customer in the queue. You must serve customers in the order they come in.
Design and implement the Least Recently Used Cache with TTL(Time To Live)
Expalnation on the eviction stragedy since people have questions on the testcase:
1, after the record expires, it still remains in the cache.
2, when the cache reaches the capacity, it first evicts the expried records. If there are more than one expired records, evict the one with the minimum expire timestamp.
You can find a word in 2d array if the word is constructed by a sequence of adjacent letters
Given a series of equations e.g. [A = B, B = D, C = D, F = G, E = H, H = C]
and then another series [A != C, D != H, ..., F != A ]
Check whether the equations combined is valid.
For the example given, your program should return 'invalid', because the first series implies that A = C, which contradicts the statement A != C in the second series.
Given an ArrayList of Nodes, with each Node having an ID and a parent ID, determine whether the List is given in preorder.
Phone Interview Amazon, Seattle
I. Get the sum of all prime numbers up to N. primeSum(N).
Follow-up: If primeSum(N) is frequently called, how to optimize it.
II. OODesign Parking Lot
AWS phone interview
Find the left view of binary tree
return [1, 2, 4, 7, 9]
1 / \ 2 3 /\ \ 4 5 6 / / 7 8 / 9
Find the indices of all anagrams of a given word in a another word.
For example: Find the indices of all the anagrams of AB in ABCDBACDAB
(Answer: 0, 4, 8)
Give a binary tree, find if it's possible to cut the tree into two halves of equal sum. You can only cut one edge.
For example, UNIQ("LETTER") = 2.
Given a string S with only uppercases, calculate the sum of UNIQ(substring) over all non-empty substrings of S.If there are two or more equal substrings at different positions in S, we consider them different. Since the answer can be very large, retrun the answer modulo 10 ^ 9 7.