Questions asked by Amazon in past 6 months- SDE2 (DSA/Design)- Part 1

Hi,
I’ve compiled a list of all the questions asked by Amazon over the last six months for the SDE-2 position. I went through various interview experiences and compiled this list based on them.
I thought it might be useful to others preparing for the role, so I’m sharing it here. Hope it helps!

Link to Part 2- https://leetcode.com/discuss/post/8519184/questions-asked-by-amazon-in-past-6-mont-ya1z/
Link to Part 3- https://leetcode.com/discuss/post/8519189/questions-asked-by-amazon-in-past-6-mont-7wjn/

  1. Topological sort and finding the cycle in the graph.
  2. LLD question was to create a publisher subscriber kind of system
    where a publisher can send events related to a particular event type and all subscribers subscribed to that event type should receive that message.
    Subscribers can subscribe and unsubscribe to a particular event type
  3. https://leetcode.com/problems/reorganize-string/description/
  4. https://leetcode.com/problems/count-stepping-numbers-in-range/description/
  5. https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/description/
  6. Design an Inventory Management System for Amazon
    The interviewer went quite deep into concurrency-related scenarios, for example:
    There is only one unit of a product left in inventory and two users place an order simultaneously. How would you prevent both orders from succeeding?
    We discussed things around:
    • Race conditions
    •Concurrency
    • Inventory consistency
    • Concurrent updates
    • Preventing overselling
    • Locking/transaction approaches
  7. https://leetcode.com/problems/container-with-most-water/description/
  8. https://leetcode.com/problems/trapping-rain-water/description/
  9. https://leetcode.com/problems/cheapest-flights-within-k-stops/description/
  10. Design a Rate Limiter
    We discussed multiple approaches/algorithms for rate limiting, including:
    • Fixed Window
    • Sliding Window
    • Token Bucket
    • Distributed rate limiting
    • Redis
    • Locks/concurrency
    • Handling rate limiting across multiple application instances
    • Trade-offs between different approaches
    The interviewer also asked follow-up questions around distributed systems and consistency.
  11. Course Schedule / Course Scheduler
  12. Closest K Elements in a Sorted Array
  13. Imagine you have a train route: G → U → H → K → I. Each segment travelled costs 1. So travelling from G to I would cost 4. The input was basically:calculateFare(start, stop)
  14. he problem was somewhat similar to an Amazon Locker, but basically the reverse. Instead of the Amazon delivery person picking up a return package from the customer, the customer books a slot at the nearest drop store and physically goes there to drop the package. I took some time initially to clarify the requirements and then started writing the code. In the middle of it, the interviewer suddenly went in another direction: "How will you find the nearest drop store from the customer's location?" I said I'd use the concept of geosharding. That's basically the only thing I could come up with because, well... I've never done HLD before. 😅 He wanted to go deeper into it and even gave me a hint: "Think about how Uber does this." Unfortunately, I didn't know how Uber does it.
  15. https://leetcode.com/problems/find-the-safest-path-in-a-grid/
  16. She gave me a custom problem, which I believe was related to something the team was actually working on. The problem was somewhat similar to syncing configurations across different devices. She asked several design-related questions, and I was able to answer all of them.
  17. Find distance between any two nodes in a tree. Parent pointers not given. Only have root, source, and target in input.
  18. Designing a stack that supports push, pop, get middle, get top in O(1) time.
  19. https://leetcode.com/problems/basic-calculator/description/
  20. LLD question was to create a publisher subscriber kind of system
    where a publisher can send events related to a particular event type and all subscribers subscribed to that event type should receive that message.
    Subscribers can subscribe and unsubscribe to a particular event type
  21. https://leetcode.com/problems/reorganize-string/description/
  22. Rotten Oranges
  23. Search in Rotated Sorted Array
    Given multiple currency conversion rates, determine the conversion rate from currency A to B.
    Example:
    • C = 10B
    • D = 9B
    • B = 110Z
    • A = 2Z
    Find the conversion rate from A to B.
    Follow-up
    Now suppose there are Q such conversion queries.
    I proposed using Disjoint Set Union (Union Find) with weighted relationships to answer repeated queries efficiently, and discussed the associated trade-offs.
  24. Decode String
  25. How do you use LLMs during development?
  26. How do you verify whether an AI-generated solution is correct?
  27. When do you trust an LLM and when do you not?
  28. Two knights are placed on an infinite chessboard. Their starting coordinates are given, and both move using standard knight moves. They move alternately. Find the minimum total number of moves required for both knights to converge at the same position.
    Given a binary string:
    • Every 0 becomes 00
    • Every 1 becomes 10
    After performing this transformation k times, determine the value at the i-th index of the final string.
  29. Minimum Window Substring
  30. Design Artifact Repository(like JFrog, adding an artifact and fetching an artifact) - Interviewer was interested in each part of my HLD, and then probed on scalability, metrics monitoring, reliability, extensibility (like dealing with a malicious artifact).
  31. Design Unix File Search API, and its extensibility to support various filters and combination of filters. First Unique Character in a string. Then extend to stream of characters.
  32. Task Scheduler
  33. Design a playlist from the DJservice and the Recommendation service to mix the songs .
    Given the list of 10 requirements printed on paper . The core idea is to mix the songs coming from the Djservice and the recommendation service , in a custom proportion or in a equal proportion . Filters can be applied based on the user preferances . Expectation is to write the production ready classes with proper syntax on paper .
  34. Given two boxes of A[] , B[] with size n , where each elements represents the sweetness , Given the M students , distribute the sweetness of A , B to each children and you should minimize the total sweetness .
  35. Find the unoccupied seat position with the maximum distance to the occupied site . Seats[] = {'O','U','U','U','O','O'}; Answer - 2nd indexed seat
  36. Given the 2 D array with 2 colours validate if it is a valid chessborad .
  37. LCS (longest common subsequence)
  38. https://leetcode.com/discuss/post/8434443/count-the-uni-valued-subtrees-in-a-binar-tqi2/
  39. Longest Strictly Increasing Subsequence with Maximum Adjacent Difference Constraint
  40. Given an array of integers and an integer k, find the length of the longest subsequence such that:
  41. The elements are strictly increasing
  42. The difference between any two consecutive elements in the subsequence is at most k
  43. The relative order of elements in the original array is maintained (it's a subsequence, not a subarray)
    Example 1:
    Input: arr = [7, 1, 4, 5, 8, 8, 10, 6, 7, 7, 7, 8], k = 4
    Output: 6
    Explanation: The longest valid subsequence is [1, 4, 5, 6, 7, 8]
    • 4 - 1 = 3 ≤ 4 ✓
    • 5 - 4 = 1 ≤ 4 ✓
    • 6 - 5 = 1 ≤ 4 ✓
    • 7 - 6 = 1 ≤ 4 ✓
    • 8 - 7 = 1 ≤ 4 ✓
    All elements appear in the same relative order as in the original array.
    Example 2:
    Input: arr = [3, 1, 2, 6, 10, 11, 4, 5], k = 3
    Output: 4
    Explanation: One valid subsequence is [1, 2, 4, 5]
    • 2 - 1 = 1 ≤ 3 ✓
    • 4 - 2 = 2 ≤ 3 ✓
    • 5 - 4 = 1 ≤ 3 ✓
    Example 3:
    Input: arr = [5, 4, 3, 2, 1], k = 2
    Output: 1
    Explanation: No two elements form a strictly increasing pair in subsequence order, so the longest valid subsequence has length 1.
    Approach: This is a variation of the Longest Increasing Subsequence (LIS) problem with an additional constraint on the maximum allowed difference between adjacent elements in the subsequence.
    Largest Subset of Binary Strings with Bounded Ones and Zeroes
    Given an array of binary strings and two integers m and n, find the size of the largest subset such that:
  44. The total number of 1s across all strings in the subset is at most m
  45. The total number of 0s across all strings in the subset is at most n
    Example 1:
    Input: strs = ["100", "10", "1", "11", "111"], m = 3, n = 0
    Output: 2
    Explanation: The largest valid subset is ["1", "11"]
    • Total 1s = 1 + 2 = 3 ≤ 3 ✓
    • Total 0s = 0 + 0 = 0 ≤ 0 ✓
    Note: ["111"] also satisfies constraints (1s = 3, 0s = 0) but has only 1 element.
    Design a Facebook-like News Feed System at Scale
    Problem Statement:
    Design a social media feed system (similar to Facebook) that supports millions of users who can post, view, and like content.
    Functional Requirements:
    • Users should be able to post any type of media (text, images, videos)
    • Users should be able to view posts in their feed
    • Like counts and view counts should be visible in real-time
    • Users should be able to like and view posts with minimal latency
    Non-Functional Requirements / Key Focus Areas:
    • Scale: Handle massive traffic — millions of concurrent users posting, liking, and viewing
    • Feed Loading Speed: The feed should render almost instantly upon login, even if the user has cleared their browser/app cache
    Discussion Points & Follow-ups:
  • API design
  • Push vs. Pull model for feed generation — trade-offs of each
  • Choice of databases — SQL vs. NoSQL vs. a combination and trade-offs
  • Caching strategy — what to cache, invalidation policies, CDN usage for media
  • Handling Viral Content (Celebrity Problem):
  • A celebrity's post goes viral with millions of likes and views in seconds — how do you prevent this from becoming a bottleneck?
  • Rate limiting, sharding/parition strategies, async processing of likes/view counters
  • Monolithic vs. Microservices — and why?
  • Service boundaries — how would you split responsibilities?
  1. Tell me about a time you used Generative AI to solve a business problem and the measurable results it delivered.
  2. Design a Music Streaming Application (like Spotify)
    Problem Statement:
    Design a music streaming platform that allows millions of users to discover, search, and stream music seamlessly.
    Functional Requirements:
    • Users should be able to search for songs, artists, and albums
    • Users should be able to create and manage playlists
    • Users should be able to like/save songs and see their library
    Non-Functional Requirements:
    • Low latency playback — music should start playing within milliseconds of pressing play
    • High availability — the service should be up 99.99% of the time
    • Scale — support millions of concurrent listeners streaming simultaneously
    Discussion Points & Follow-ups:
  • API design
  • How do you serve audio files efficiently to millions of concurrent users?
  • CDN strategy for audio content distribution across geographies
  • How and where to store millions of audio files (object storage, metadata DB)
  • Choice of database for song metadata, user data, playlists
  • Storing listening history and user preferences for recommendations
  • How to design a fast search system across millions of songs, artists, and albums
  • Indexing strategies, full-text search (Elasticsearch/similar)
  • Load balancing and horizontal scaling of streaming servers
  • Monolithic vs. Microservices — service boundaries (streaming service, search service, recommendation service, user service, playlist service)
  1. Tell me about a time you used Generative AI to automate or streamline a workflow.

  2. Search an Element in a Sorted Rotated Array. Given a sorted array that has been rotated at some pivot point, search for a target element and return its index. Return -1 if not found.

  3. How do you be a compitent software engineer in this era of Gen AI?

  4. Design HLD (30 mins) for device backup scheduler and restore
    Should backup device settings, files, media, etc
    Restore on new devices

  5. Unorthodox question around String Manipulation to find next palindromic time of given time "HH:MM". (MEDIUM)

  6. Variation to find kth smallest sum of integers in row wise sorted m*n matrix . Only pick 1 element from each row (HARD)

  7. Design and implement Meeting Room Scheduler.

  8. Aggressive cows

  9. https://leetcode.com/problems/find-median-from-data-stream/
    Design a notification router for an ecommerce website

  10. The user should have a preferred channel (EMAIL, SMS, PUSH)

  11. Notification has a priority attribute (URGENT, NORMAL)

  12. If the notification is urgent, it should be sent to all channels otherwise it should only be sent to the user's preferred channel.

  13. The notification handlers need not to be implemented, only routing logic was needed.

  14. Find unique permutations of a given string - For example, s = "xxyy"

  15. First permutation = "xxyy"
    Second permutation = "xxyy" -> Swap the 0th and 1st index "x" characters

  16. But the output should contain "xxyy" only once. I had to return the list containing all the unique permutations

  17. 3Sum closest

  18. Number of Islands II

  19. https://leetcode.com/problems/course-schedule-ii/

  20. https://leetcode.com/problems/merge-intervals/

  21. https://leetcode.com/problems/product-of-array-except-self/

  22. Design: Google Docs (Collaborative Document Editing)
    Key areas discussed:
    • Real-time collaboration
    o Operational Transformation (OT) vs CRDTs for conflict resolution
    o WebSocket connections for low-latency sync
    • Storage and versioning
    o Delta-based storage for document history
    o Snapshot + diff strategy for efficient retrieval
    • Scalability — sharding by document ID, regional replication
    • Presence indicators (who's editing what, cursor positions)
    • Permissions and access control model

  23. Design: Uber (Ride-Hailing System)
    Key areas discussed:
    • Class design — Rider, Driver, Trip, Payment, Location entities
    • Trip state machine: requested → accepted → in_progress → completed / cancelled
    • Driver matching algorithm — geospatial indexing (quadtree / geohash)
    • Surge pricing logic and fare calculation service
    • Payment service integration — idempotency, retries, failure handling
    • API design — REST endpoints for booking, tracking, and cancellation

  24. https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/

  25. https://leetcode.com/problems/reorganize-string/
    Amazon receives transfer notifications whenever money moves between accounts.
    Transfers form a chain, for example:
    A → B → C → D
    Input is provided as pairs:
    [A, B]
    meaning money moved from A to B.
    Task:
    Find:
    • Initial source account
    • Final destination account
    Example:
    numberOfTransfers = 3
    transferList = [
    (222, 111),
    (111, 333),
    (444, 222)
    ]
    Output:
    start = 444
    end = 333
    Explanation:
    444 → 222 → 111 → 333

  26. Design Amazon Locker System
    Requirements discussed:
    • Delivery driver deposits package
    • Customer receives code
    • Customer unlocks locker using code
    • Locker allocation
    • OTP/code validation
    • Expiry handling
    • Multiple locker sizes
    • Scalability
    • Availability
    • Failure handling
    Topics interviewer focused on:
    • API design
    • Database schema
    • Concurrency handling
    • Distributed locking
    • Scalability
    • Performance optimization
    • Notification flow
    • State transitions

  27. Secure the Network by Disconnecting One Facility Center
    A company has a network of Facility Centers (FCs) represented as a graph. Some FCs are compromised. If a compromised FC is connected to other FCs, the compromise spreads to all directly or indirectly connected nodes. You are allowed to disconnect exactly one compromised FC. Find which FC to remove such that the maximum number of clean FCs are saved. (If multiple FCs save the same number of nodes, return the FC with the smallest ID).
    • Similar to: Minimize Malware Spread
    Key Discussion Areas:
    • Connected components
    • DFS / Union Find
    • Edge cases and constraints
    • Time and Space Complexity

  28. Design a Shipping Cost Calculator. Design a system to calculate shipping costs based on multiple dynamic conditions, including weight, distance, delivery type, priority shipping, region-based pricing, and special handling.

  29. Given an array of delivery times, output the median of all values seen so far after each new delivery time arrives.
    Input: [5, 17, 100, 11]
    Output: [5, 5, 17, 11]
    Approach: Solved using the Two Heaps pattern (Max-Heap and Min-Heap).

  30. Given values in houses arranged in a line, find the maximum value that can be stolen without robbing two adjacent houses.
    Input: [6, 7, 1, 3, 8, 2, 4]
    Output: 19

  31. Design the core architecture for a food delivery platform like Zomato.
    Key Discussion Areas:
    • Restaurant onboarding & Menu management
    • Search & Discovery
    • Order placement & Payments
    • Delivery assignment & Real-time tracking
    • Notifications

  32. Employee Ratings Management System
    A company maintains ratings for employees and needs to process operations in real time.
    Operations:

  33. 1 x : Add an employee with rating x.

  34. 2 : Print the highest rating AND the index of the employee having the highest rating (If multiple employees have the same highest rating, return the first occurrence).

  35. 3 i : Delete the employee at index i (Note: Indices shift after deletion).
    Challenge: Designing an efficient data structure supporting Insert, Delete-by-index, and Query-max + first-occurrence simultaneously.

  36. https://leetcode.com/problems/binary-tree-cameras/description/

  37. Given a string s, remove duplicate letters so every letter appears exactly once. Remove Duplicate Letters
    BUT with a twist.
    Original LC 316 asks for:
    smallest lexicographical
    Amazon changed it to:
    largest lexicographical
    That means same monotonic stack pattern, but reverse comparison logic.
    Return the largest lexicographical possible result.

  38. given the n sorted list and merge them.

  39. given a list of Nodes in a N-ary tree, and given a level you have to return the nodes at the level.

  40. Trapping rain water

  41. Max consecutive ones III - https://leetcode.com/problems/max-consecutive-ones-iii/

  42. maximum profit in job scheduling - https://leetcode.com/problems/maximum-profit-in-job-scheduling/

  43. Given two strings str and pattern, return an array of all the start indices of pattern's anagrams in str.
    Input: str = "acbadabcaa", pattern = "aabc" Output: [0,5,6] Explanation:

    The substring with start index = 0 is "acba", which is an anagram of "aabc".
    The substring with start index = 5 is "abca", which is an anagram of "aabc".
    The substring with start index = 6 is "bcaa", which is an anagram of "aabc".

  44. Given an m x n grid of 0 (Water) and 1 (Land), the task is to count the number of islands.
    An island is a group of adjacent 1 cells connected horizontally, vertically, or diagonally,
    and it is surrounded by water or the grid boundary. The goal is to determine how many distinct islands exist in the grid.

    Input: grid[][] =
    [[1, 1, 0, 0, 0],
    [0, 1, 0, 0, 1],
    [1, 0, 0, 1, 1],
    [0, 0, 0, 0, 0],
    [1, 0, 1, 1, 0]]

    Number of Islands = 4

  45. There are N poles of various heights, and you have a machine whose saw blade can be set at a specific height "h"
    and it cuts all poles till that height, such that all of them have height "h" after the cut.
    (Poles with height less than "h" remain uncut). You take away the cut portions of all poles with you.

Your task is to take at least M length of poles with you in total after the cut.
What is the maximum height 'h' where you can set your blade to achieve this.

N = 4
M = 7
arr = [20, 15, 10, 17]

  1. Proper time and space complexity asked
  2. Find the number of unique pairs in a 2d matrix whose sum = target (Numbers are unique)
  3. Dijkstra algortihm
  4. Binary search
  5. First positive missing - https://leetcode.com/problems/first-missing-positive/description/
  6. Word break II - https://leetcode.com/problems/word-break-ii/description/
  7. https://leetcode.com/problems/word-break/description/
  8. Given a grid whose cells are 'O' and 'X', latter being a blokcer. Given source and destination, find if there is a path exists
    between source and destination. You can only travel down or take a right turn.
  9. Course schedule 2
  10. Binary tree right view
  11. Next permutation
  12. Construct the tree with level order and inorder traversal
  13. Longest happy prefix - https://leetcode.com/problems/longest-happy-prefix/description
Comments (11)