Help us with your details

Oops! Something went wrong while submitting the form.
Our June 2021 cohorts are filling up quickly. Join our free webinar to Uplevel your career

Top Amazon Coding Interview Questions Asked

You can download a PDF version of  
Amazon Coding Interview Questions
Download PDF

Do you know that only about 2% of those who apply at Amazon get through? The tech giant has a pretty rigorous hiring process. The recruiters carefully select all the Amazon interview questions to test the overall abilities of the applicants. 

To face the Amazon coding interview questions, a lot of practice, guidance, and the correct strategy are required. As the company receives thousands of resumes every year, you’ll need to really ace your tech interview to get through.

If you are intent on acing Amazon’s coding interview, you must adopt the right strategy. Without that, beating the stiff competition is an uphill climb. 

In this article, we’ll look at the type of Amazon coding interview questions you can expect. These are the things we will discuss:

  • What is Unique About Amazon’s Interview Process?
  • The Amazon Interview Process
  • Sample Amazon Coding Interview Questions
  • FAQs on Amazon Interview Questions

What Is Unique About Amazon’s Interview Process?

For the most part, the Amazon interview process is similar to other FAANG companies. However, they have a couple of key rounds or methods that make the interview process unique. 

The Loop

The Loop is Amazon on-site interview — it is centered around the company’s 14 leadership principles. Recruiters evaluate you against these leadership principles either directly or indirectly at any stage of the on-site. 

The Bar Raiser

Amazon also has a special “Bar Raiser” round, where specially trained employees (known as Bar Raisers) gauge if you’re the right fit. The primary function of the “Bar Raisers” is to maintain the hiring bar high by seeking out only the best talent. They have a decisive say in the interview’s outcome, so even if you ace the core technical rounds, you have to pass the bar raiser round to lock an offer. 

The Amazon Interview Process

Amazon coding interview questions are a crucial part of the process. But, apart from those, there are other two important stages too. The Amazon technical interview has these main stages:

  1. The initial phone screen
  2. The Amazon coding assignment
  3. The Loop

Let’s look at what happens in each of these rounds:

1. The Initial Phone Screen

This round happens with a recruiter from Amazon who will get in touch with you after your profile gets provisionally shortlisted for the role. The recruiter will ask you questions about your experience, core skills, and expectations from the role. 

You can also expect a couple of behavior-related questions in this round. At the end of the interview, the recruiter will set a date for the coding assignment.

For more details on Amazon phone questions and how to answer them, check out the Amazon Phone Interview Questions article.

2. The Amazon Coding Assignment

Depending on the role you’re applying to, the coding assignment happens either remotely or in person. For most developer positions, the coding assignment happens remotely. Considering the pandemic situation, Amazon decided that it would hold remote assignments that would be monitored in real time.

The coding assignment involves solving 1-2 coding problems within a stipulated time period. It usually happens on a coding interview platform or a Google Doc. The hiring manager evaluates your approach to solving the problems and how you go about arriving at the solution. At the end of the assignment, expect a few questions around the concepts you employed to solve the problem(s). 

If your performance in the Amazon coding interview questions is satisfactory, a recruiter will get in touch with you to fix a date for the on-site interview. 

3. The Loop

Amazon’s on-site interview, known as the Loop, is the final phase in the hiring process. Getting through this stage is significantly challenging as recruiters assess you on a number of aspects before making a hiring decision. 

The loop typically consists of the following rounds:

  1. Coding round: This round involves solving 1-2 Amazon coding interview questions around algorithms and data structures. The extent of your problem-solving skills is assessed in this round. 
  2. Design round: Hiring managers in this round evaluate your engineering design skills. Your ability to design and work with scalable systems with low latency is assessed.  
  3. Behavioral round: Behavioral interviews at Amazon are based on the company’s 14 leadership principles. The behavioral round is essentially built to test if your attitude and personality traits align with the company’s vision and goals.   
  4. The bar-raiser round: Bar raisers are a group of handpicked employees trained to maintain the hiring bar at Amazon. Their primary role is to find the best candidates for the role by assessing them against a set of predefined parameters. Bar raisers have a veto when recruiters make a hiring decision. If they happen to deem you unfit for the role, you don’t get offered. 

Note: Amazon tends to focus more on behavioral and design interviews for senior positions and coding interviews for junior positions. Additionally, coding interviews don’t have a veto while hiring for senior positions but design interviews have a veto for junior positions. 

Amazon Interview Questions

Amazon asks coding interview questions about algorithms and data structures. In the below sections, we look at questions from topics that feature in Amazon’s tech interview. 

Amazon Interview questions on Arrays

Arrays are a popular data structure around which questions are asked in technical interviews. Below are some common Amazon coding interview questions on arrays:

  1. Given: Array A of size N
    Task: Perform operations such as searching an element, inserting an element, and deleting an element by completing the functions. Also, all functions should return a boolean value
  2. Given: Array A of size N
    Task: Print elements of A in an alternate order (starting from index 0)
  3. Task: Write a code to find the minimum and maximum element in an array
  4. Given: Array Arr of size N
    Task: Print the second largest element from the array
  5. Given: Array A of size N of integers
    Task: Find the minimum and maximum elements in the array
  6. Given: An unsorted array arr[] of size N
    Task: Rotate it by D elements (clockwise) 
  7. Given: A sorted array A of size N
    Task: Delete all duplicate elements from A
  8. Given: An unsorted array arr[] of n positive integers
    Task: Find the number of triangles that can be formed with three different arrays elements if the elements were lengths of the three sides of the triangle. 
  9. Given: An array A of positive integers
    Task: Find the leaders in the array (an element is a leader if it is greater than or equal to all the elements to its right) 
  10. Given: An array A of N elements
    Task: Find minimum index-based distance between two elements, x, and y
  11. Given: An array A of N integers
    Task: Find any 3 elements in it such that A[i] < A[j] < A[k] and i < j < k
  12. Given: An array A of N elements
    Task: Find the majority element in the array (a majority element in an array A of size N is an element that appears more than N/2 times in the array)
  13. Given: A sorted array arr[] of distinct integers
    Task: Sort the array into a wave-like array and return it — arrange the elements into a sequence such that a1 >= a2 <= a3 >= a4 <= a5 ...
  14. Given: An array A[] of N positive integers
    Task: Write a code to find the maximum of j - i, subject to the constraint A[i] <= A[j]
  15. Given: An array nums[] of size N
    Task: Construct a Product Array P (of same size N) such that P[i] is equal to the product of all the elements of nums except nums[i]
  16. Given: An array of size N and a range [a, b]
    Task: Partition the array around the range such that the array is divided into three parts:  All elements smaller than a come first; all elements in range a to b come next; all elements greater than b appear in the end
  17. Given: An array A of size N (the elements of the array are distinct and are sorted)
    Task: Find all pairs in the array that add up to a number K 
  18. Given: An array arr[] of N non-negative integers representing the height of blocks
    Task: If the width of each block is 1, write a code to calculate how much water can be trapped between the blocks during the rainy season
  19. Given: An array of integers
    Task: Find the inversion count in the array (the inversion count determines how far away the array is from being sorted) 
  20. Given: An array arr[] of N integers
    Task: Calculate the median

Amazon Interview Questions on Strings

Strings are a popular data type used to represent text characters. Below are coding questions you can expect on strings during an Amazon tech interview: 

  1. Given: String S
    Check if it is palindrome or not
  2. Given: Two strings a and b consisting of lowercase characters
    Task: Write a code to check whether the two strings are anagrams of each other
  3. Given: String S
    Check if characters of the given string can be rearranged to form a palindrome 
  4. Given: String str
    Task: Convert the first letter of each word in the string to uppercase
  5. Given: String str containing only lower case alphabets
    Task: Sort it in lexicographically-descending order
  6. Given: Two strings S1 and S2
    Write a program to merge them alternatively — the first character of S1 with the first character of S2, and so on — till the end of the string
  7. Given: String S containing alphanumeric characters
    Task: Find out whether the string is a palindrome or not
  8. Given: String S
    Task: Reverse the string without reversing its individual words
  9. Task: Write a code to implement the function strstr. The function essentially takes two strings as arguments (s,x) and locates the occurrence of the string X in the string S 
  10. Given: Two strings A and B
    Task: Find if A is a subsequence of B
  11. Given: Two strings s1 and s2
    Task: Write a code to check if s2 is a rotated version of the string s1
  12. Given: Two strings of lowercase alphabets and a value K
    Write a program function that tells if the two strings are K-anagrams of each other
  13. Given: Two strings A and B
    Task: Find the characters that are not common in the two strings
  14. Given: A string S consisting of lowercase Latin letters
    Task: Find the first non-repeating character in S
  15. Given: A string S
    Find the length of the longest substring with all distinct characters
  16. Given: A string,
    Task: Find the longest substring that is a palindrome in linear time O(N).
  17. Given: A decimal number m
    Convert it into a binary string and apply n iterations. In each iteration, 0 becomes 01, and 1 becomes 10. Find the kth (1-indexing) character in the string after nth iteration
  18. Given: Two binary strings A and B consisting of only 0s and 1s
    Task: Find the resultant string after adding the two strings
  19. Given: Two numbers as strings s1 and s2
    Task: Calculate their product
  20. Given: Two binary strings A and B
    Task: Find the product of two strings in decimal value

Amazon Interview Questions on Sorting

Sorting is a crucial topic for coding interviews. Below are some Amazon interview questions on sorting algorithms. 

  1. Given: An array arr[] of size N
    Check if it is sorted in non-decreasing order
  2. Given: A binary array A[] of size N
    Arrange the array in increasing order
  3. Given: An array of size N containing only 0s, 1s, and 2s
    Task: Sort the array in ascending order
  4. Given: an integer N and a list arr
    Sort the array using the bubble sort algorithm
  5. Given: An unsorted array of size N
    Task: Use selection sort to sort arr[] in increasing order
  6. Given: An array arr[], its starting position “low,” and its ending position “high”
    Task: Implement the partition() and quickSort() functions to sort the array
  7. Given: An array arr[], its starting position l, and its ending position r
    Task: Sort the array using the merge sort algorithm
  8. Given: Two integer arrays A1[ ] and A2[ ] of size N and M, respectively
    Task: Sort the first array A1[ ] such that all the relative positions of the elements are the same as the elements in the second array A2[ ]
  9. Given: An integer array of which both first half and second half are sorted
    Task: Write a code to merge the two sorted halves of the array into a single sorted array
  10. Given: An array arr of size n and an integer X
    Task: Find if there's a triplet in the array which adds up to an integer X
  11. Given: An array of n distinct elements
    Task: Find the minimum number of swaps required to sort the array in increasing order
  12. Given: An array A of integers
    Task: Find three numbers such that the sum of two elements equals the third element — return the triplet in a container result

Amazon Interview Questions on Hashing

Amazon asks problems that employ hashing quite regularly in coding interviews. Here are some practice questions on hashing. 

  1. Given: An NxN matrix M
    Write a program to find the count of all the distinct elements common to all rows of the matrix
  2. Given: Two arrays a1[0..n-1] of size n and a2[0..m-1] of size m
    Task: Write a code to check whether a2[] is a subset of a1[] or not
  3. Given: A set of N nuts of different sizes and N bolts of different sizes — there is a one-one mapping between nuts and bolts
    Task: Write a code to match the nuts and bolts
  4. Given: An array A[] of N positive integers, which can contain integers from 1 to P, where elements can be repeated or can be absent from the array
    Task: Write a code to count the frequency of all elements from 1 to N
  5. Given: Two arrays A and B of equal size N
    Task: Find if the given arrays are equal or not
  6. Given: An array of N integers
    Task: Find the first element that occurs K number of times
  7. Given: Two arrays A and B containing integers of size N and M
    Write a program to find numbers that are present in the first array but not present in the second array
  8. Given: An array arr of N integers
    Task: Find the first non-repeating element 
  9. Given: An array of strings
    Task: Write a code to return all groups of strings that are anagrams
  10. Given: An array N with positive numbers
    Task: Write a code to find the largest subsequence from an array that contains elements that are Fibonacci numbers
  11. Given: An array of N integers, and an integer K
    Find the number of pairs of elements in the array whose sum is equal to K
  12. Given: An integer array and a non-negative integer k
    Task: Count all distinct pairs with the difference equal to k —  A[ i ] - A[ j ] = k

Amazon Interview Questions on Recursion

Recursion is an important concept in technical interviews and can be a tricky area to master. Here are some practice Amazon coding interview questions on recursion for your upcoming interview.

  1. Task: Write a code to print a sequence of numbers starting with N, where A[0] = N, without using a loop, in which  A[i+1] = A[i] - 5, until A[i] > 0. After that A[i+1] = A[i] + 5. Repeat it until A[i] = N
  2. Given: A round table of n persons
    Task: Write a code to find out in how many ways they can  shake hands such that no two handshakes cross each other
  3. Given: n number of people in a circle and a number k, such that k-1 persons are skipped, and the kth person is eliminated
    Task: Write a code to figure out the safest place in the circle
  4. Given: A string s
    Task: Remove all its adjacent duplicate characters recursively
  5. Given: An image of size n*m, location of a pixel in the screen(sr, cc) and color nColor
    Task:  Write a code to replace the color of a given pixel and all adjacent same-colored pixels with a new color “nColor”

Amazon Interview Questions on Graphs and Greedy Algorithms

Graphs and Greedy Algorithms are extremely important concepts that you must master if you wish to ace Amazon’s technical interview. Here are some questions on Graphs. 

  1. Given: Adjacency list of a bidirectional graph
    Task: Write a code to return the adjacency list for each vertex
  2. Given: A directed graph
    Task: Write a code to perform breadth-first traversal of this graph starting from 0
  3. Given: A connected undirected graph
    Task: Write a program to perform depth-first traversal of the graph
  4. Given: A grid of size n*n filled with 0, 1, 2, 3
    Task: Check whether there is a path possible from the source to destination (you can traverse left, right, up, or down)
  5. Given: A square chessboard, the initial position of the Knight, and the position of a target
    Task: Write a code to find the minimum steps required by the knight to reach the target position
  6. Given: An adjacency list of a graph adj with V number of vertices and having 0-based index
    Task: Write a code to find whether the graph is bipartite or not
  7. Given: A 2D binary matrix A(0-based index) of dimensions NxM
    Task: Find the minimum number of steps required to reach from (0,0) to (X, Y)
  8. Given: A directed graph with V vertices (numbered from 0 to V-1) and E edges
    Task: Find the number of strongly connected components in the graph
  9. Given: A directed graph
    Task: Find if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph
  10. Given: A weighted, undirected, and connected graph of V vertices and E edges
    Task: Write a code to find the sum of weights of the edges of the minimum spanning tree
  11. Given: Weights and values of N items
    Task: Put these items in a knapsack of capacity W to get the maximum total value in the knapsack
  12. Given: N activities with their start date and finish date in array start[ ] and end[ ]
    Task: Select the maximum number of activities that can be performed by a single person, assuming that a person can only work on a single activity in a given day
  13. Given: Arrival and departure times of all trains that reach a railway station
    Task: Find the minimum number of platforms required for the railway station such that no train is kept waiting
  14. Given: A set of N jobs, where each job “I” has a deadline and profit associated with it. Each job takes 1 unit of time to complete and only one job can be scheduled at a time. A profit can be earned if the job is completed before the deadline
    Task: Write a code to find the maximum profit earned and maximum number of jobs that can be done 

Mathematical Problems for the Amazon Interview

Amazon sometimes asks problems around mathematics, where you have to code the solution to a mathematical problem. Below are some Amazon coding interview questions:

  1. Given: The first 2 terms A1 and A2 of an arithmetic series
    Task: Find the Nth term of the series
  2. Given: The first term and common ratio X and R of a GP series
    Task: Find the nth term of the series
  3. Given: Two non-zero integers N and M
    Task: Find the number closest to N and divisible by M. If there are more than one such number, then output the one having maximum absolute value
  4. Given: A 3-digit number
    Task: Find whether it is an Armstrong number or not (an Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself — for example, 371 is an Armstrong number, since 33 + 73 + 13 = 371)
  5. Given: A number N
    Task: Find if the sum of digits of N is a Palindrome number or not 
  6. Given: A positive number X
    Task: Find the largest Jumping Number smaller than or equal to X (a number is called Jumping Number if all adjacent digits in it differ by only 1. All single digit numbers are considered Jumping Numbers. For example: 7, 8987, and 4343456 are Jumping Numbers, but 796 and 89098 are not)
  7. Given: Binary number B
    Task: Find its decimal equivalent
  8. Given: Two numbers A and B
    Task: Find Kth digit at the right of AB
  9. Given: A number N
    Task: Write a code to reverse its digits
  10. Given: A number N
    Task: Check if a number is perfect or not (a number is said to be perfect if the sum of all its factors excluding the number itself is equal to the number)
  11. Given: A number N
    Task: Write a code to find the largest prime factor of that number
  12. Given: Two integers n and r
    Task: Find nCr (the answer may be very large, so calculate the answer modulo 109+7)
  13. Task: Write a program to calculate nPr — nPr represents n permutation r and the value of nPr is (n!) / (n-r)!
  14. Given: A positive integer,] N
    Task: Find the factorial of N
  15. Given: An array of N positive integers
    Task: Find GCD of all the array elements
  16. Given: N
    Task: Count all “a”(>=1) and “b”(>=0) that satisfy the condition a3 + b3 = N
  17. Given: Two numbers (n , m)
    Task: Write a code to find n√m (nth root of m)
  18. Given: A number N
    Task: Calculate the prime numbers up to N using Sieve of Eratosthenes
  19. Given: A positive integer N
    Task: Find the sum of all prime numbers between 1 and N(inclusive)

Amazon Systems Design Interview Questions

Distributed systems design is an important component in the on-site interview. The design round is particularly important for senior developer and managerial positions. Below are some Amazon coding interview questions pertaining to distributed and large-scale systems.

  1. Design an in-memory database system
  2. Design an IP blocking system
  3. Design a voting system, where people will cast their votes and the votes get added to corresponding candidates
  4. Design a system to find 100 top-selling products in a given time window
  5. Design an Amazon online bookstore, where users can view prices and make purchases
  6. Design a system where an office administrator knows how many people are present on each floor of the building, given that the building has 3 floors
  7. Design a system to upload images with tags — users would be able to visit and search for images by entering the tags
  8. Design a notification service that sends notifications to multiple devices
  9. Design a comprehensive workflow system that responds to pause/continue functions
  10. Design a scheduler service that can manage huge schedules with minimal latency 

For more details on Amazon system design questions and how to answer them, check out the Amazon System Design Interview Questions article. 

Amazon Behavioral Interview Questions

Amazon’s behavioral interview is starkly different from other FAANG companies. To get a feel of what sort of questions to expect, we’ve listed some for you below: 

  1. Tell us about a time a project you were working on went south. How did you manage the situation?
  2. Tell us about a time when your work-life balance was thrown off gear owing to a demanding project.
  3. Tell us about a time when you leveraged massive chunks of data to build a strategy. How did you execute it?
  4. Why do you want to work at Amazon? How do you think Amazon will impact your life in the coming years?
  5. What would be your stand if your supervisor asked you to do something outside the purview of the company’s policy?
  6. Tell us about a time when it was getting difficult to work with an uncooperative colleague.
  7. Tell us about a time when you apprised the entire team about crucial learnings that you derived while working on a project.

For more details on Amazon behavioral interview questions and how to answer them, check out the “Amazon Behavioral Interview Questions” article. 

Landing a software engineer job at Amazon is hard, given its rigorous interview process. Nailing it requires the right strategy and direction. 

Our “FAANG Interview Tips” is a good place to start your Amazon technical interview prep.

FAQs on Amazon Coding Interview Questions

Q1. How hard is the Amazon coding interview?

No matter whether you’re a fresher or an experienced professional, the Amazon coding interview is pretty hard. You’ll be given a 2-hour 2-question technical coding test that is intentionally hard so as to weed out the unqualified applicants.

Q2. What questions can be expected in an Amazon coding interview?

Some topics you can expect questions on are: Arrays, Linked lists, Trees, Strings, and Dynamic programming.

Q3. What questions should be asked at the end of an Amazon interview?

Some questions are: What does a typical day look like for an employee in this role? How is success defined in this position? What’s the biggest challenge Amazon faces today?

Q4. How to crack the Amazon coding interview?

You practice and then practice some more. Research the interview process as thoroughly as you can so that you’re prepared for the interview. Take part in competitive programming to become faster and more efficient, and if there’s anything else, do reach out to us.

Q5. How many rounds are there in the Amazon interview process?

The process consists of 5 rounds, each lasting about an hour (phone screening and on-site interviews). 

Are You Ready to Nail Your Next Coding Interview?

If you are looking for help and guidance on how to prepare for that big interview, consider Interview Kickstart

As pioneers in the field of technical interview prep, we have trained thousands of software engineers to crack the toughest coding interviews and land jobs at their dream companies, such as Google, Facebook, Apple, Netflix, Amazon, and more!

Sign up for our free webinar to learn more!

Recommended Posts

About usWhy usInstructorsReviewsCostFAQContactBlogRegister for Webinar