Amazon Interview Questions

Prepare for success with our curated collection of interview questions. Designed to help students practice and build confidence, these questions cover a range of topics and real-world scenarios to get you ready for your next interview.
Q1: LRU Cache
  • Design and implement an LRU cache with given capacity.
  • Discuss time and space complexities for get and put operations.
  • Why is LinkedHashMap (or equivalent) often used? Can you implement without built-ins?
  • Given two strings, find the longest subsequence common to both.
  • How would you optimize space complexity?
  • How would you modify LCS to handle multiple strings?
  • LFU Cache design.
  • Edit Distance (minimum operations to convert string A to B).
  • Design a data structure for autocomplete with prefix queries.

Find the maximum length of consecutive 1s in a binary array if you are allowed to flip at most k zeros.

Given an integer array, you can change at most k elements to make them equal. Find the longest subarray of equal values.

In a binary array, determine the minimum number of flips needed so that at least one subarray of length m contains only 1s.

If the array is circular, compute the maximum number of consecutive 1s achievable by flipping at most k zeros.

Given jobs with startTime, endTime, and profit, find the maximum profit achievable without overlapping jobs.

Each job has a cooldown period after completion. Maximize profit while respecting this delay before starting the next job.

You may select at most k jobs without overlap. Find the maximum profit possible.

If jobs can be repeated indefinitely (as long as they don’t overlap), find the maximum profit schedule.

Given tasks and cooldown n, find the minimum number of intervals required to finish all tasks.

Extend Q9 where tasks have different execution durations, not just 1 unit.

Up to k tasks can run simultaneously per interval. Find the minimum total time.

Tasks arrive in real-time. Design an online scheduler that respects cooldown n efficiently.

Evaluate a string with integers, +, -, (, ), and spaces (no eval).

Extend Q13 to also handle multiplication and division with precedence rules.

Include exponentiation (^) and handle parentheses correctly.

Evaluate expressions as characters arrive in a stream, instead of full string upfront.

Use all tickets exactly once starting from “JFK” to form the smallest lexicographical path.

If tickets can be reused, find the itinerary with the maximum number of flights from “JFK”.

Handle cycles in tickets while ensuring a valid itinerary with smallest lexical order.

Instead of reconstructing the path, check if an itinerary exists that uses all tickets starting at “JFK”.

Remove exactly k digits from a number string to form the smallest integer.

Modify Q21 to form the largest possible integer after removing k digits.

Allow removing up to k digits (not exactly). Find the smallest possible integer.

Digits arrive one by one; decide online whether to keep or remove (at most k) to minimize the final number.

Q1. Bus Ticket Booking System

Design a scalable system with APIs and database schema to manage bus seat booking, handle seat allocation fairly, and ensure correctness under high concurrency (e.g., two users trying to book the same seat at the same time).

Design and implement an LRU (Least Recently Used) cache as a reusable library. It should be thread-safe, efficient, and scalable for real-world applications.

Design a parking lot system supporting multiple vehicle types (car, bike, bus, etc.), flexible billing rules (hourly, daily), and efficient space allocation.

Design an end-to-end system for customers to browse restaurants, place orders, make payments, and track delivery. Include APIs, DB schema, and scalability considerations.

Design a system to handle ride requests, driver allocation (matching riders to nearby drivers), trip tracking, and payment processing.

Decide how to represent airline tickets in code (adjacency list, adjacency matrix, or custom structure) for efficient route reconstruction.

Handle cases where multiple tickets exist between the same source and destination. Ensure correct representation and traversal.

Design a helper class that stores routes and builds the itinerary while maintaining lexicographical order as required.

Implement a class with a method reduce(num, k) that removes k digits from a number to form the smallest possible integer.

Identify and test edge cases such as "100200", "10", "9", etc., ensuring correctness under all conditions.

Refactor the logic so that it works for both numeric strings and integer inputs in a clean, reusable way.

Implement the AllOne data structure with proper encapsulation of Node and Bucket objects for O(1) increment, decrement, getMaxKey, and getMinKey operations.

Extend the AllOne class to support iteration so that it can be used in a loop (for key in allOne:).

Add persistence to the AllOne data structure so it can be saved to disk and reloaded across sessions.

Create a clean API, e.g., SubarraySolver.maxSumWithDeletion(arr), that solves the maximum subarray sum problem with at most one deletion.

Design test cases for tricky arrays like [1,-2,0,3], [1,-2,-2,3], [-1,-1,-1,-1] to validate correctness.

Extend the class so that it not only returns the maximum sum but also the indices of the subarray achieving this sum.

Implement a utility class with method removeSmallest(s) that removes duplicate letters to return the smallest lexicographical string with unique characters.

Modify the function to also handle strings containing uppercase letters, digits, or special characters.

Write test cases for tricky inputs such as "bcabc", "cbacdcbc", "aaaaa" to ensure correct behavior.

Design a class MatrixAnalyzer with a method rowWithMaxOnes(mat) that finds the row containing the maximum number of 1s.

Write tests for scenarios like:

  • All rows having equal number of ones.
  • Only one row having maximum ones.
  • A matrix with a single row or a single column.

Extend the class so that instead of returning just one row, it can also return all rows that tie for the maximum number of 1s.

Q1. Book Recommendation System

Design a scalable and low-latency recommendation system that suggests books based on user preferences, history, and trends. Consider personalization, data storage, and real-time response.

Design a system to shorten long URLs into unique short links with fast redirection. Handle scalability, analytics (clicks, geo data), and high availability.

Build a notification system that supports Email, SMS, and Push notifications. Consider message queuing, retries, prioritization, and user preferences.

Design a product catalog system with efficient search, filtering, and sorting capabilities. Handle millions of products with scalability and quick retrieval.

Design a file storage and sharing system supporting uploads, access control, collaboration, and versioning. Ensure reliability, scalability, and efficient storage.

Design a system to compute itineraries from flight tickets at large scale (millions of records). Focus on route optimization and query efficiency.

Modify the itinerary planner to handle thousands of concurrent user searches. Consider caching, indexing, and distributed computation.

Add resilience to the itinerary planner when ticket data is missing, inconsistent, or delayed. Ensure correctness and graceful degradation.

If number reduction (removing digits for optimization) is part of a banking system, design how it would integrate securely and efficiently.

Adapt the number reduction logic to work with continuous incoming streams of digits instead of a single static input.

Ensure the number reduction system can handle millions of requests per second while maintaining accuracy and low latency.

Design an architecture to count word frequencies in real-time search queries, ensuring scalability and low-latency updates.

Distribute the key-value frequency data structure across multiple servers while keeping operations (increment, getMax, getMin) efficient.

Handle scenarios where the number of unique keys is extremely large by optimizing memory usage (e.g., compression, eviction, sharding).

Apply the maximum subarray sum with one deletion logic to stock trading (ignoring at most one bad day). Ensure scalability for massive datasets.

Adapt the max subarray sum algorithm to handle very large arrays coming as a continuous data stream.

Integrate the max subarray sum computation into a live dashboard that updates continuously as new data arrives.

Use duplicate-removal logic for compilers to remove redundant tokens while maintaining correct order in lexical analysis.

Scale string de-duplication to handle millions of strings in real-time (e.g., logs, social media streams).

Extend duplicate-removal logic to support complex characters including Unicode scripts and emojis.

Apply the “row with max ones” problem to image analysis, e.g., finding the row with the brightest pixels.

Handle matrices too large to fit in memory by processing them in chunks or using streaming techniques.

Scale matrix analysis across multiple servers to efficiently handle very high-dimensional datasets.

WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.