You can download a PDF version of

Amazon Coding Interview Questions

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

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 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.

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.

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:

- The initial phone screen
- The Amazon coding assignment
- The Loop

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

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.

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.

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:

**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.**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.**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.**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 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.

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

**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**Given:**Array A of size N**Task:**Print elements of A in an alternate order (starting from index 0)**Task:**Write a code to find the minimum and maximum element in an array**Given:**Array Arr of size N**Task:**Print the second largest element from the array**Given:**Array A of size N of integers**Task:**Find the minimum and maximum elements in the array**Given:**An unsorted array arr[] of size N**Task:**Rotate it by D elements (clockwise)**Given:**A sorted array A of size N**Task:**Delete all duplicate elements from A**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.**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)**Given:**An array A of N elements**Task:**Find minimum index-based distance between two elements, x, and y**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**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)**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 ...**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]**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]**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**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**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**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)**Given:**An array arr[] of N integers**Task:**Calculate the median

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:

**Given:**String**S**Check if it is palindrome or not

Task:**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**Given:**String**S**Check if characters of the given string can be rearranged to form a palindrome

Task:**Given:**String str**Task:**Convert the first letter of each word in the string to uppercase**Given:**String**str**containing only lower case alphabets**Task:**Sort it in lexicographically-descending order**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

Task:**Given:**String**S**containing alphanumeric characters**Task:**Find out whether the string is a palindrome or not**Given:**String S**Task:**Reverse the string without reversing its individual words**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****Given:**Two strings A and B**Task:**Find if A is a subsequence of B**Given:**Two strings s1 and s2**Task:**Write a code to check if s2 is a rotated version of the string s1**Given:**Two strings of lowercase alphabets and a value**K**Write a program function that tells if the two strings are

Task:**K-anagrams**of each other**Given:**Two strings A and B**Task:**Find the characters that are not common in the two strings**Given:**A string**S**consisting of**lowercase**Latin letters**Task:**Find the first non-repeating character in S**Given:**A string**S**Find the length of the longest substring with all distinct characters

Task:**Given:**A string,**Task:**Find the longest substring that is a palindrome in linear time O(N).**Given:**A decimal number**m**Convert it into a binary string and apply

Task:**n**iterations. In each iteration,**0**becomes**01**, and**1**becomes**10**. Find the**k**th (1-indexing) character in the string after**n**th iteration**Given:**Two binary strings**A**and**B**consisting of only 0s and 1s**Task:**Find the resultant string after adding the two strings**Given:**Two numbers as strings s1 and s2**Task:**Calculate their product**Given:**Two binary strings A and B**Task:**Find the product of two strings in decimal value

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

**Given:**An array**arr[]**of size**N**Check if it is sorted in non-decreasing order

Task:**Given:**A binary array**A[]**of size**N**Arrange the array in increasing order

Task:**Given:**An array of size N containing only 0s, 1s, and 2s**Task:**Sort the array in ascending order**Given:**an integer**N**and a list**arr**Sort the array using the bubble sort algorithm

Task:**Given:**An unsorted array of size N**Task:**Use selection sort to sort arr[] in increasing order**Given:**An array arr[], its starting position “low,” and its ending position “high”**Task:**Implement the partition() and quickSort() functions to sort the array**Given:**An array arr[], its starting position l, and its ending position r**Task:**Sort the array using the merge sort algorithm**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[ ]**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**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**Given:**An array of n distinct elements**Task:**Find the minimum number of swaps required to sort the array in increasing order**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 asks problems that employ hashing quite regularly in coding interviews. Here are some practice questions on hashing.

**Given:**An**N**x**N**matrix**M**Write a program to find the count of all the distinct elements common to all rows of the matrix

Task:**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**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**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**Given:**Two arrays A and B of equal size N**Task:**Find if the given arrays are equal or not**Given:**An array of**N**integers**Task:**Find the first element that occurs**K**number of times**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

Task:**Given:**An array**arr**of**N**integers**Task:**Find the first non-repeating element**Given:**An array of strings**Task:**Write a code to return all groups of strings that are anagrams**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**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

Task:**K****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

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.

**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**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**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**Given:**A string s**Task:**Remove all its adjacent duplicate characters recursively**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”

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.

**Given:**Adjacency list of a bidirectional graph**Task:**Write a code to return the adjacency list for each vertex**Given:**A directed graph**Task:**Write a code to perform breadth-first traversal of this graph starting from 0**Given:**A connected undirected graph**Task:**Write a program to perform depth-first traversal of the graph**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)**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**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**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)**Given:**A directed graph with**Task:**Find the number of strongly connected components in the graph**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**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**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**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**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**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

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

**Given:**The first 2 terms A1 and A2 of an arithmetic series**Task:**Find the Nth term of the series**Given:**The first term and common ratio X and R of a GP series**Task:**Find the nth term of the series**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**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)**Given:**A number N**Task:**Find if the sum of digits of N is a Palindrome number or not**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)**Given:**Binary number B**Task:**Find its decimal equivalent**Given:**Two numbers A and B**Task:**Find Kth digit at the right of AB**Given:**A number N**Task:**Write a code to reverse its digits**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)**Given:**A number N**Task:**Write a code to find the largest prime factor of that number**Given:**Two integers n and r**Task:**Find nCr (the answer may be very large, so calculate the answer modulo 109+7)**Task:**Write a program to calculate nPr — nPr represents n permutation r and the value of nPr is (n!) / (n-r)!**Given:**A positive integer,] N**Task:**Find the factorial of N**Given:**An array of N positive integers**Task:**Find GCD of all the array elements**Given:**N**Task:**Count all “a”(>=1) and “b”(>=0) that satisfy the condition a3 + b3 = N**Given:**Two numbers (n , m)**Task:**Write a code to find n√m (nth root of m)**Given:**A number N**Task:**Calculate the prime numbers up to N using Sieve of Eratosthenes**Given:**A positive integer N**Task:**Find the sum of all prime numbers between 1 and N(inclusive)

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.

- Design an in-memory database system
- Design an IP blocking system
- Design a voting system, where people will cast their votes and the votes get added to corresponding candidates
- Design a system to find 100 top-selling products in a given time window
- Design an Amazon online bookstore, where users can view prices and make purchases
- 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
- Design a system to upload images with tags — users would be able to visit and search for images by entering the tags
- Design a notification service that sends notifications to multiple devices
- Design a comprehensive workflow system that responds to pause/continue functions
- 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’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:

- Tell us about a time a project you were working on went south. How did you manage the situation?
- Tell us about a time when your work-life balance was thrown off gear owing to a demanding project.
- Tell us about a time when you leveraged massive chunks of data to build a strategy. How did you execute it?
- Why do you want to work at Amazon? How do you think Amazon will impact your life in the coming years?
- What would be your stand if your supervisor asked you to do something outside the purview of the company’s policy?
- Tell us about a time when it was getting difficult to work with an uncooperative colleague.
- 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.

**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).

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!