Amazon Interview Questions (43+ Questions)
Last Updated: June 8, 2026 • 43 Questions • Real Company Interviews
Prepare for your Amazon interview with our comprehensive collection of 43+ real interview questions and detailed answers. These questions have been curated from actual Amazon technical interviews across various roles including DevOps Engineer, Data Engineer, QA Engineer, and more.
Table of Contents
- Performance-Based Backend Selection (easy) 🔒
- Handling Large Log Archives (easy)
- Container With Most Water (medium)
- Extract and Normalize Timestamps from Multi-Format Log File (medium)
- Merge k Sorted Lists (hard)
- Configure AWS IAM Password Policy (easy) 🔒
- Walls and Gates (medium)
- Audit and Enforce Least-Privilege IAM Permissions (easy)
- Create an ECR Repository with Security and Cross-Account Access (medium) 🔒
- Build a Serverless API with Lambda, API Gateway, and DynamoDB (hard)
- Deploy a Highly Available ECS Application with RDS (hard) 🔒
- Event-Driven Order Processing with EventBridge Fan-Out (hard) 🔒
- Blue/Green Deployment with ALB Weighted Target Groups (hard) 🔒
- Cross-VPC Connectivity for ECS and RDS (hard) 🔒
- Architect a Segregated Multi VPC Network with Centralized Routing (hard)
- Monthly Hiring Trend by Department (easy) 🔒
- Ranking with Dense_Rank (medium)
- Combine Aggregates with UNION ALL (easy) 🔒
- Advanced JOIN with Three Tables (easy) 🔒
- Flatten Nested JSON to CSV with Dot-Notation Columns (medium)
- Count Daily Customers and Total Call Duration (easy)
- Numeric Age from Rock Sample (easy)
- Category Stats (medium)
- Product Summary (medium)
- Global & Domain SEO Leaders (hard)
- Factory Data Cleanup (medium)
- Average Height Per Floor (easy)
- Product Reorder Suggestion Query (medium) 🔒
- LFU Cache (hard)
- Moving Average from Data Stream (easy)
- Return Rate Comparison across Categories (medium) 🔒
- Average Review Ratings (easy)
- Order Items Average (easy)
- Active Customer Analysis (easy)
- Employee Salary Ranking Analysis (medium)
- Highest-Grossing Items (medium)
- Complete Category Buyers (medium)
- Prime Batch Warehouse Capacity (hard)
- Senior Manager Direct Reports (hard)
- Server Fleet Uptime (hard)
- Promotional Campaign Effectiveness (medium) 🔒
- Device Ecosystem API Testing (medium) 🔒
- Button Click Testing (easy) 🔒
Our Amazon interview questions cover a wide range of technical topics and difficulty levels, from entry-level positions to senior roles. Each question includes detailed explanations and answers to help you understand the concepts and prepare effectively for your interview.
💡 Pro Tips for Amazon Interviews
- Practice each question and understand the underlying concepts
- Review Amazon's specific technologies and methodologies
- Prepare follow-up questions and edge cases
- Practice explaining your solutions clearly and concisely
Interview Questions & Answers
1. Performance-Based Backend Selection
Learn how to measure disk write performance and select appropriate storage backends using Linux Bash commands. This guide covers benchmarking sequential write speeds, interpreting results, and making data-driven infrastructure decisions, essential for matching storage solutions to application requirements and ensuring performance in data-intensive workloads.
2. Handling Large Log Archives
Learn how to split large log files into manageable chunks using Linux Bash commands. This guide covers breaking gigabyte-sized logs into smaller files with sequential naming, preserving the original file, and verifying the split process, essential for parallel log analysis, incident investigation, and handling massive logs in DevOps environments.
3. Container With Most Water
def max_area(height: list[int]) -> int:
l, r = 0, len(height) - 1
res = 0
while l < r:
area = (r - l) * min(height[l], height[r])
res = max(res, area)
if height[l] < height[r]:
l += 1
else:
r -= 1
return res
4. Extract and Normalize Timestamps from Multi-Format Log File
Use regular expressions to extract timestamps from log entries in various formats (ISO 8601, Apache, RFC 2822), parse them using Python datetime, and convert all timestamps to a uniform ISO 8601 format.
5. Merge k Sorted Lists
Definition for singly-linked list.
class ListNode:
def init(self, val=0, next=None):
self.val = val
self.next = next
def merge_k_lists(lists: list[Optional[ListNode]]) -> Optional[ListNode]:
min_heap = []
for i, l in enumerate(lists):
if l:
heapq.heappush(min_heap, (l.val, i, l))
dummy = ListNode(0)
tail = dummy
while min_heap:
val, i, node = heapq.heappop(min_heap)
tail.next = node
tail = tail.next
if node.next:
heapq.heappush(min_heap, (node.next.val, i, node.next))
return dummy.next
6. Configure AWS IAM Password Policy
Set up an AWS account-wide IAM password policy to enforce minimum length, character requirements, and prevent password reuse using AWS CLI.
7. Walls and Gates
def walls_and_gates(rooms: list[list[int]]) -> list[list[int]]:
if not rooms or not rooms[0]:
return rooms
rows, cols = len(rooms), len(rooms[0])
q = deque()
INF = 2147483647
for r in range(rows):
for c in range(cols):
if rooms[r][c] == 0:
q.append((r, c))
directions = [[1, 0], [-1, 0], [0, 1], [0, -1]]
while q:
r, c = q.popleft()
for dr, dc in directions:
nr, nc = r + dr, c + dc
if 0 <= nr < rows and 0 <= nc < cols and rooms[nr][nc] == INF:
rooms[nr][nc] = rooms[r][c] + 1
q.append((nr, nc))
return rooms
8. Audit and Enforce Least-Privilege IAM Permissions
Audit an IAM user with overly broad permissions, identify attached policies, and replace them with a least-privilege custom policy scoped to only the services the user actually needs.
9. Create an ECR Repository with Security and Cross-Account Access
Create an ECR repository with tag immutability, a lifecycle policy to expire old untagged images, and a repository policy granting cross-account pull access.
10. Build a Serverless API with Lambda, API Gateway, and DynamoDB
Create a serverless API using AWS Lambda and API Gateway that stores and retrieves data from a DynamoDB table, with a least-privilege IAM execution role and no direct database exposure.
11. Deploy a Highly Available ECS Application with RDS
Deploy a highly available containerized application on ECS Fargate with RDS, ALB, ECR, and Secrets Manager across multiple Availability Zones with proper network isolation and security groups.
12. Event-Driven Order Processing with EventBridge Fan-Out
Build an event-driven architecture using EventBridge, SQS, SNS, and CloudWatch to fan out order events to multiple independent consumers with dead-letter handling and least-privilege access.
13. Blue/Green Deployment with ALB Weighted Target Groups
Implement a blue/green deployment strategy using Auto Scaling Groups, ALB weighted target groups, launch templates, and Secrets Manager for zero-downtime deployments with instant rollback capability.
14. Cross-VPC Connectivity for ECS and RDS
Configure secure cross-VPC connectivity using VPC Peering so that an ECS Fargate application in one VPC can access a private RDS database in another VPC with proper routing, DNS resolution, and security group controls.
15. Architect a Segregated Multi VPC Network with Centralized Routing
Test your enterprise networking skills by designing a secure, hub-and-spoke AWS Transit Gateway architecture with strict traffic segmentation and centralized VPC Flow Logs.
16. Monthly Hiring Trend by Department
Mastering the Interview Question:
Counting Employee Hires per Month by Department in SQL
Objective
To tackle this SQL interview question, we're given two tables: employees and departments. Our goal is to determine the number of employees hired each month for every department.
E...
🔒 Premium Content
Detailed explanation and solution available for premium members.
17. Ranking with Dense_Rank
SEO-Friendly Explanation: SQL Interview Question on Sales Rankings
If you're preparing for a SQL interview, understanding how to compute rankings based on aggregated data is essential. One common question you might encounter involves computing total sales for each salesperson and ranking them accordingly using SQL. Below you will find a detailed explanation of how to tackle such a question, making sure your solution is both efficient and adheres to best practices.
Objective
Your task is to write a SQL query that computes total sales for each salesperson from a table named sales and assigns a dense rank based on these totals in descending order. Salespeople with identical total sales should receive the same rank, and there should be no gaps in the sequence.
Additional Information
Table Schema:
- sales:
salesperson_id(INTEGER): Unique identifier for each salesperson.salesperson_name(VARCHAR): Name of the salesperson.sale_amount(INTEGER): Amount of an individual sale.
Constraints:
- The
salestable contains at least one record. - Total sales for each salesperson are calculated as the sum of their
sale_amountvalues. - Utilize SQL window functions to determine the sales rankings.
Output Requirements:
- Columns to return:
salesperson_name: Name of the salesperson.total_sales: Sum of all sales amounts for the salesperson.sales_rank: Dense rank based ontotal_salesin descending order.
- Order the results first by
sales_rankin ascending order, then bysalesperson_namein ascending order.
SQL Query Solution
Here is the SQL query to achieve the objective:
SELECT
salesperson_name,
total_sales,
DENSE_RANK() OVER (ORDER BY total_sales DESC) AS sales_rank
FROM
(
SELECT
salesperson_id,
salesperson_name,
SUM(sale_amount) AS total_sales
FROM
sales
GROUP BY
salesperson_id,
salesperson_name
) AS sales_summary
ORDER BY
sales_rank ASC,
salesperson_name ASC;
Explanation of the SQL Query
- Subquery (sales_summary): First, we use a subquery to compute the total sales for each salesperson. We do this by selecting
salesperson_id,salesperson_name, and theSUM(sale_amount)grouped bysalesperson_idandsalesperson_name. - Main Query: In the main query, we select
salesperson_nameandtotal_salesfrom the subquery. We also compute thesales_rankusing theDENSE_RANK()window function, ordering bytotal_salesin descending order. - Order By Clause: Finally, we order the entire result set by
sales_rankin ascending order, and then bysalesperson_namein ascending order to meet the output requirements.
This query ensures a seamless ranking sequence with no gaps, even when multiple salespeople have the same total sales amount. By summarizing sales and computing ranks in a single query, you can efficiently generate the required output while showcasing your SQL proficiency in an interview setting.
18. Combine Aggregates with UNION ALL
How to Tackle the SQL Interview Question: Summarize Online and Offline Orders
When interviewing for a position that involves working with SQL, one common question you might encounter is:
Objective
Create a SQL query that retrieves a summary of orders from two separate sources: online and ...
🔒 Premium Content
Detailed explanation and solution available for premium members.
19. Advanced JOIN with Three Tables
Objective
Write an SQL query that retrieves the customer name, order date, payment amount, and payment date for all payments greater than $1000. The results should be sorted in descending order of payment amount and, for payments with the same amount, by ascending order date.
Additional inf...
🔒 Premium Content
Detailed explanation and solution available for premium members.
20. Flatten Nested JSON to CSV with Dot-Notation Columns
Convert nested JSON objects to flat CSV format using dot-notation for nested fields and comma-separated strings for arrays with pandas in Python.
21. Count Daily Customers and Total Call Duration
SELECT
date,
COUNT(DISTINCT cust_id) AS num_customers,
SUM(duration) AS total_duration
FROM {{ ref("calls") }}
GROUP BY date
22. Numeric Age from Rock Sample
SELECT
sample_id,
description,
COALESCE(REGEXP_SUBSTR(description, '[0-9]+'), '') AS age
FROM {{ ref("rock_samples") }}
23. Category Stats
Join products with orders and compute per-category average price and order count.
24. Product Summary
Combine product, sales, and inventory data using left joins with null handling.
25. Global & Domain SEO Leaders
Master advanced PySpark Window functions by calculating both partition-level and global maximums. Learn how to use empty window partitions and conditional F.when() logic to identify top-performing SEO pages.
26. Factory Data Cleanup
Practice cleaning and merging manufacturing data in PySpark. Learn how to remove exact duplicate rows using dropDuplicates() before joining multiple DataFrames together.
27. Average Height Per Floor
SELECT
id,
name,
city,
country,
CASE
WHEN floors != 0
THEN ROUND(height_m / floors, 2)
ELSE 0
END AS avg_height_per_floor
FROM {{ ref("buildings") }}
28. Product Reorder Suggestion Query
Identifying Products for Reorder in Inventory Using SQL
Objective
In this task, you'll write an SQL query to identify products in the inventory that need to be reordered. For each product that requires reordering, you'll calculate the suggested order quantity with the formula: `CEIL((reorder...
🔒 Premium Content
Detailed explanation and solution available for premium members.
29. LFU Cache
from collections import defaultdict, OrderedDict
class LFUCache:
def init(self, capacity):
self.cap = capacity
self.min_freq = 0
self.key_val = {}
self.key_freq = {}
self.freq_keys = defaultdict(OrderedDict)
def _update(self, key):
freq = self.key_freq[key]
self.freq_keys[freq].pop(key)
if not self.freq_keys[freq] and self.min_freq == freq:
self.min_freq += 1
self.key_freq[key] = freq + 1
self.freq_keys[freq + 1][key] = None
def get(self, key):
if key not in self.key_val:
return -1
self._update(key)
return self.key_val[key]
def put(self, key, value):
if self.cap <= 0:
return
if key in self.key_val:
self.key_val[key] = value
self._update(key)
return
if len(self.key_val) >= self.cap:
evict_key, _ = self.freq_keys[self.min_freq].popitem(last=False)
del self.key_val[evict_key]
del self.key_freq[evict_key]
self.key_val[key] = value
self.key_freq[key] = 1
self.freq_keys[1][key] = None
self.min_freq = 1
30. Moving Average from Data Stream
from collections import deque
class MovingAverage:
def init(self, size):
self.size = size
self.queue = deque()
self.window_sum = 0
def next(self, val):
self.queue.append(val)
self.window_sum += val
if len(self.queue) > self.size:
self.window_sum -= self.queue.popleft()
return self.window_sum / len(self.queue)
31. Return Rate Comparison across Categories
How to Calculate the Return Rate of Orders for Each Product Category Using SQL
Objective
In a SQL interview, you might encounter a challenging yet intriguing question: Write a SQL query to calculate the return rate of orders for each product category. The return rate is defined as the per...
🔒 Premium Content
Detailed explanation and solution available for premium members.
32. Average Review Ratings
SELECT
DATE_TRUNC('month', review_date) AS review_month,
product_id,
ROUND(AVG(star_rating)) AS avg_rating
FROM
product_reviews
GROUP BY
DATE_TRUNC('month', review_date),
product_id
ORDER BY
review_month ASC,
product_id ASC;
33. Order Items Average
SELECT
ROUND(
SUM(item_count * order_occurrences)::DECIMAL / SUM(order_occurrences),
1
) AS mean_items
FROM
items_per_order;
34. Active Customer Analysis
SELECT
COUNT(policy_holder_id) AS policy_holder_count
FROM
(
SELECT
policy_holder_id,
COUNT(case_id) AS call_count
FROM
callers
GROUP BY
policy_holder_id
HAVING
COUNT(case_id) >= 3
) AS frequent_callers;
35. Employee Salary Ranking Analysis
SELECT
MAX(salary) AS second_highest_salary
FROM
employee
WHERE
salary < (
SELECT
MAX(salary)
FROM
employee
);
36. Highest-Grossing Items
SELECT
category,
product,
total_spend
FROM
(
SELECT
category,
product,
SUM(spend) AS total_spend,
RANK() OVER (
PARTITION BY
category
ORDER BY
SUM(spend) DESC
) AS ranking
FROM
product_spend
WHERE
EXTRACT(
YEAR
FROM
transaction_date
) = 2022
GROUP BY
category,
product
) AS ranked_products
WHERE
ranking <= 2
ORDER BY
category,
total_spend DESC;
37. Complete Category Buyers
SELECT
cp.customer_id
FROM
customer_purchases cp
JOIN product_catalog pc ON cp.product_id = pc.product_id
GROUP BY
cp.customer_id
HAVING
COUNT(DISTINCT pc.category) = (
SELECT
COUNT(DISTINCT category)
FROM
product_catalog
)
ORDER BY
cp.customer_id;
38. Prime Batch Warehouse Capacity
WITH
summary AS (
SELECT
item_type,
SUM(item_count) AS batch_count,
SUM(square_footage * item_count) AS total_sqft
FROM
inventory
GROUP BY
item_type
)
SELECT
item_type,
CASE
WHEN item_type = 'prime_eligible' THEN batch_count
ELSE FLOOR(
(
500000 - (
SELECT
total_sqft
FROM
summary
WHERE
item_type = 'prime_eligible'
)
) * batch_count::DECIMAL / total_sqft
)
END AS max_batch_count
FROM
summary
ORDER BY
item_type DESC;
39. Senior Manager Direct Reports
WITH
managers AS (
SELECT DISTINCT
manager_id AS employee_id
FROM
employees
WHERE
manager_id IS NOT NULL
),
manages_managers AS (
SELECT DISTINCT
e.manager_id AS employee_id
FROM
employees e
JOIN managers m ON e.employee_id = m.employee_id
WHERE
e.manager_id IS NOT NULL
)
SELECT
mgr.employee_name AS senior_manager_name,
COUNT(*) AS direct_report_count
FROM
manages_managers mm
JOIN employees mgr ON mm.employee_id = mgr.employee_id
JOIN employees e ON e.manager_id = mm.employee_id
WHERE
NOT EXISTS (
SELECT
1
FROM
employees sub
JOIN manages_managers mm2 ON sub.employee_id = mm2.employee_id
WHERE
sub.manager_id = mm.employee_id
)
GROUP BY
mgr.employee_name
ORDER BY
direct_report_count DESC,
senior_manager_name;
40. Server Fleet Uptime
WITH
sessions AS (
SELECT
server_id,
status_time,
session_status,
LEAD(status_time) OVER (
PARTITION BY
server_id
ORDER BY
status_time
) AS stop_time
FROM
server_utilization
)
SELECT
FLOOR(
SUM(
EXTRACT(
EPOCH
FROM
(stop_time - status_time)
)
) / 86400
)::INT AS total_uptime_days
FROM
sessions
WHERE
session_status = 'start';
41. Promotional Campaign Effectiveness
Understanding the SQL Query to Identify High-Impact Promotional Campaigns
When tackling an interview question about SQL queries for identifying influential promotional campaigns, there are several key components you need to consider.
Objective
Your task is to write a SQL query that identi...
🔒 Premium Content
Detailed explanation and solution available for premium members.
42. Device Ecosystem API Testing
Apple's ecosystem connects over 2 billion active devices worldwide across iPhone, iPad, Mac, Apple Watch, and Apple TV. QA testing of Apple device ecosystem APIs requires comprehensive validation of device registration, sync services, iCloud backup management, and cross-platform data sharing to ensu...
🔒 Premium Content
Detailed explanation and solution available for premium members.
43. Button Click Testing
Master simple button click testing with Selenium. Learn basic element interaction and click verification for beginners....
🔒 Premium Content
Detailed explanation and solution available for premium members.
Ready to Practice More?
Explore interview questions from other companies or try our hands-on labs to build practical experience.