most common AMAZON coding interview questions
below is a list of the 15 most frequently asked questions in an Amazon interview
For detailed solutions to each question, you can visit
Grokking the Coding Interview: Patterns for Coding Questions
find the missing number in the array
You are given an array containing ‘n’ distinct numbers taken from the range 0 to ‘n’. Since the array has only ‘n’ numbers out of the total ‘n+1’ numbers, find the missing number.
Determine if the sum of two integers is equal to the given value
Given an array of integers and a value, determine if there are any two integers in the array whose sum is equal to the given value.
merge two sorted linked lists
Given two sorted linked lists, merge them so that the resulting linked list is also sorted.
Copy linked list with arbitrary pointer
You are given a linked list where the node has two pointers. The first is the regular ‘next’ pointer. The second pointer is called ‘arbitrary_pointer’ and it can point to any node in the linked list.
Your job is to write code to make a deep copy of the given linked list. Here, deep copy means that any operations on the original list (inserting, modifying and removing) should not affect the copied list.
Given a binary tree, perform a zigzag level order traversal
Given a binary tree, populate an array to represent its zigzag level order traversal. You should populate the values of all nodes of the first level from left to right, then right to left for the next level and keep alternating in the same manner for the following levels.
Determine if a binary tree is a binary search tree
Given a Binary Tree, figure out whether it’s a Binary Search Tree. In a binary search tree, each node’s key value is smaller than the key value of all nodes in the right subtree, and are greater than the key values of all nodes in the left subtree i.e. L < N < R.
longest substring with no more than 'k' distinct characters
Given a string, find the length of the longest substring in it with no more than K distinct characters.
longest substring with no repeating characters
Given a string, find the length of the longest substring which has no repeating characters.
how many ways can you make change with coins and a total amount
Given coin denominations and total amount, find out the number of ways to make the change.
Math and stats
find kth permutation
Given a set of ‘N’ elements, find the Kth permutation.
Find all subsets of a given set of integers
You are given a set of integers and you have to find all the possible subsets of this set of integers.
print balanced brace combinations
Print all braces combinations for a given value 'N' so that they are balanced.
clone a directed graph
Given the root node of a directed graph, clone this graph by creating its deep copy so that the cloned graph has the same vertices and edges as the original graph.
sorting and searching
find 'k' closest points to the origin
Given an array of points in the a 2D plane, find ‘K’ closest points to the origin.
find the Top 'k' frequent numbers in an array
Given an unsorted array of numbers, find the top ‘K’ frequently occurring numbers in it.
have you been asked a question that is not included here in your amazon interview?
please share with us:
Need help preparing for the interview?
Check out the Definitive Interview Prep Roadmap,
written and reviewed by real hiring managers.