Unite Wings

Amazon interview questions

29 questions candidates report from Amazon interviews, plus the general HR questions every interviewer asks. Each has a model answer and the follow-ups to expect.

Typical selection process

Online assessment (two coding questions plus a work-style survey), then two or three interviews. Every round mixes coding with Leadership Principles questions.

As reported by recent candidates. Always check the latest official notification.

46 questions

BehaviouralCourageHard

Tell me about a time you disagreed with your manager, professor or team lead.

Reported at Amazon, Microsoft, Google

What they are checking: At Amazon this maps to "Have Backbone; Disagree and Commit". They want respectful challenge backed by data, and full commitment once a decision is made.

Model answer

During my internship my team lead wanted to cache the entire product catalogue in memory to speed up search. I was worried because the catalogue was growing about 10% a month and our servers had limited memory.

I didn't just object. I measured it: the catalogue was 1.2 GB, and at that growth rate it would exceed the server's free memory in about five months. I shared those numbers in a short doc and suggested caching only the top 5,000 most-searched products, which covered about 80% of queries according to our logs.

My lead agreed to try my version first. Search time dropped from 800 ms to around 120 ms for most users, and memory use stayed flat. Had he decided to cache everything anyway, I would have committed to it and set up a memory alert so we'd know before it became a problem.

Tips

  • Disagree with data, not opinion.
  • Show that you would commit fully even if the decision went the other way.

Likely follow-ups

  • What if the data had supported your lead?
  • What did you do about the other 20% of queries?
BehaviouralCustomer focusMedium

Tell me about a time you went out of your way for a customer or user.

Reported at Amazon, Flipkart

What they are checking: Customer Obsession, Amazon's first Leadership Principle. They want you to start from the user's problem.

Model answer

I built a library seat-booking app for our college. A week after launch, I noticed in the logs that about 30% of bookings were never used, so students were being turned away from empty seats.

I spent two evenings in the library asking students why. Most no-shows were people who booked a slot but whose class ran late. I added a 15-minute check-in window: if you don't scan the QR code at your seat in time, the seat is released and the next person in the waiting list gets a notification.

No-shows fell to about 8%, and the librarian asked the administration to make the app official for all students. The fix was not technically hard; the important part was asking users what was really happening.

BehaviouralProblem solvingHard

What is the most technically challenging problem you have solved?

Reported at Google, Microsoft, Amazon

What they are checking: Depth. They will keep asking "why" until they reach the limit of what you know, so pick something you understand completely.

Model answer

In my internship, our app's order page sometimes showed duplicate orders, roughly 1 in 500. Nobody could reproduce it locally.

I added logging with request IDs and found that duplicates always came in pairs about 300 ms apart. The mobile app retried a request whenever the network was slow, and our server processed both requests because it had no way to tell they were the same order.

I proposed an idempotency key: the app generates a unique ID per order, and the server stores it with a unique constraint in the database. A second request with the same ID returns the original order instead of creating a new one. I wrote the migration, the server change and tests that simulated the retry.

Duplicate orders went to zero over the following month. The thing I learned is to reproduce with data from production before guessing at a fix.

Likely follow-ups

  • Why a database constraint and not a check in code?
  • How long do you keep the idempotency keys?
  • What happens if two requests arrive at exactly the same moment?
BehaviouralBias for ActionHard

Tell me about a time you made a decision without having all the information.

Reported at Amazon

What they are checking: Amazon's "Bias for Action": speed matters, and many decisions can be reversed. They want calculated risk-taking.

Model answer

During our college fest I managed online ticket sales. Two days before the event, the payment gateway we used started failing for about 20% of transactions, and their support said a fix could take a week.

I didn't know whether the problem would get worse, and I didn't have time to properly compare alternatives. But it was a reversible decision: I could keep both options open. Within a few hours I added UPI payment by QR code as a second option, with manual confirmation by our team, while keeping the original gateway live.

We sold 1,800 tickets, about 400 of them through the backup. Afterwards I wrote a short note for next year's team recommending a backup payment method from the start.

Tips

  • Say why the decision was reversible or the risk was acceptable.
  • Use numbers.
BehaviouralDive DeepHard

Tell me about a time when the numbers did not add up and you had to dig deeper.

Reported at Amazon

What they are checking: "Dive Deep": leaders know the details and are sceptical when metrics and anecdotes disagree.

Model answer

In my data analytics internship, our weekly dashboard showed signups up 40% in one week, and everyone was celebrating a new marketing campaign.

The jump seemed too large, so I looked at the raw data. About 35% of the new signups came from just three IP ranges and had email addresses with random strings. They were bots, not customers.

I showed my manager the breakdown, and we added a CAPTCHA and filtered bot signups from the dashboard. The real growth was about 6%, which was still good, but now the team made budget decisions on true numbers.

BehaviouralInvent and SimplifyMedium

Tell me about a time you found a simpler way to do something.

Reported at Amazon

What they are checking: "Invent and Simplify".

Model answer

Our department collected internship certificates from 240 students every semester by email. A faculty coordinator then typed the details into a spreadsheet by hand, which took her about two weeks.

I built a Google Form connected to a Google Sheet, with an Apps Script that renamed each uploaded file with the student's roll number and checked that the internship dates were valid. Students submitted in a minute, and the coordinator got a clean sheet automatically.

Processing time went from two weeks to one day, and the department now uses the same form for three other kinds of submissions. It cost nothing and took me one weekend.

TechnicalOperating systemsMedium

What is a deadlock? What conditions cause it and how can you prevent it?

Reported at TCS, Infosys, Microsoft, Amazon

What they are checking: Concurrency fundamentals.

Model answer

A deadlock is when two or more processes wait for each other forever. Thread A holds lock 1 and waits for lock 2, while thread B holds lock 2 and waits for lock 1.

All four conditions must hold at the same time (the Coffman conditions):

  • Mutual exclusion: a resource can be held by only one process.
  • Hold and wait: a process holds one resource while waiting for another.
  • No preemption: resources cannot be taken away forcibly.
  • Circular wait: a cycle of processes, each waiting for the next.

Prevention means breaking any one condition. The most practical is to break circular wait by always acquiring locks in a fixed global order. Other options are timeouts on lock acquisition, or acquiring all needed resources at once. Avoidance algorithms like the Banker's algorithm check that granting a request keeps the system in a safe state.

TechnicalDatabasesMedium

When would you choose a SQL database and when a NoSQL database?

Reported at Amazon, Flipkart, Accenture

What they are checking: Whether you understand trade-offs rather than trends.

Model answer

SQL databases (MySQL, PostgreSQL) store data in tables with a fixed schema and relationships, support joins, and give strong ACID guarantees. NoSQL databases (MongoDB, DynamoDB, Cassandra, Redis) use documents, key-value pairs or wide columns, have flexible schemas, and are built to scale horizontally.

Choose SQL when:

  • Data is structured and related, such as orders, customers and payments.
  • You need transactions that must be correct, such as transferring money.
  • You need complex queries and reports with joins.

Choose NoSQL when:

  • The schema changes often or varies per record, such as product catalogues with different attributes.
  • You need huge scale with simple access patterns, such as a shopping cart or session store looked up by key.
  • You need very fast reads of denormalised data.

Many real systems use both: PostgreSQL for orders and payments, Redis for caching, and a document store for the catalogue.

TechnicalDatabasesMedium

What are ACID properties?

Reported at Infosys, Accenture, Amazon

What they are checking: Understanding of transactions, often illustrated with a bank transfer.

Model answer

ACID describes what a database guarantees for a transaction. Take transferring ₹500 from A to B:

  • Atomicity: all or nothing. Either both the debit from A and the credit to B happen, or neither does.
  • Consistency: the transaction moves the database from one valid state to another; rules such as "balance cannot be negative" are never broken.
  • Isolation: concurrent transactions don't see each other's half-finished work; two transfers from A at the same time behave as if run one after the other.
  • Durability: once committed, the transfer survives a crash or power failure, because it is written to disk or a log.
TechnicalNetworkingHard

What happens when you type a URL into the browser and press Enter?

Reported at Google, Microsoft, Amazon, Flipkart

What they are checking: Breadth across networking, the web and browsers. Go step by step, and go deep where you are strongest.

Model answer

  1. URL parsing: the browser works out the protocol (https), the domain and the path.
  2. DNS lookup: it finds the IP address of the domain, checking the browser cache, the OS cache, the router and then the ISP's DNS resolver, which may query root, TLD and authoritative name servers.
  3. TCP connection: the browser opens a connection to the IP on port 443 with a three-way handshake (SYN, SYN-ACK, ACK).
  4. TLS handshake: browser and server agree on encryption, the server proves its identity with a certificate, and they set up session keys.
  5. HTTP request: the browser sends GET /path with headers such as cookies and accepted formats.
  6. Server side: a load balancer passes the request to an app server, which may check a cache, query a database and build the response.
  7. HTTP response: status code, headers and the HTML body come back.
  8. Rendering: the browser parses HTML into the DOM and CSS into the CSSOM, runs JavaScript, then lays out and paints the page. Extra requests are made for images, scripts and stylesheets, often from a CDN.

Interviewers usually stop you at one step and ask for more depth, most often DNS, TLS or rendering.

Likely follow-ups

  • How does DNS caching work?
  • What is a CDN?
  • What changes with HTTP/2?
TechnicalCodingEasy

Given an array and a target, return the indices of two numbers that add up to the target.

Reported at Amazon, Google, Microsoft, Flipkart

What they are checking: Whether you move from the brute-force O(n²) solution to a hash map.

Model answer

Brute force checks every pair: O(n²). Better: as you scan, store each number's index in a hash map, and for each number check whether target minus that number has already been seen. O(n) time, O(n) space.

def two_sum(nums, target):
    seen = {}
    for i, x in enumerate(nums):
        if target - x in seen:
            return [seen[target - x], i]
        seen[x] = i
    return []

print(two_sum([2, 7, 11, 15], 9))   # [0, 1]

If the array is sorted, two pointers from both ends solve it in O(n) time and O(1) space.

Likely follow-ups

  • What if there are many pairs and you must return all of them?
  • Solve three-sum.
TechnicalCodingMedium

Reverse a singly linked list.

Reported at Microsoft, Amazon, Zoho

What they are checking: Pointer manipulation, a Microsoft favourite.

Model answer

Walk the list with three pointers: prev, curr and next. At each node, point curr.next back to prev, then move all three forward. O(n) time, O(1) space.

class Node:
    def __init__(self, val, next=None):
        self.val = val
        self.next = next

def reverse(head):
    prev = None
    curr = head
    while curr:
        nxt = curr.next
        curr.next = prev
        prev = curr
        curr = nxt
    return prev

Draw the pointers on paper for a three-node list while explaining; it shows the interviewer you aren't reciting from memory. The recursive version is shorter but uses O(n) stack space.

Likely follow-ups

  • Reverse the list in groups of k.
  • Detect a cycle in a linked list.
TechnicalCodingEasy

Find the first non-repeating character in a string.

Reported at Amazon, Flipkart, Microsoft

What they are checking: Hash map counting, and whether you notice that two passes are enough.

Model answer

Count each character in one pass, then scan again and return the first character with a count of 1. O(n) time, and O(1) extra space for a fixed alphabet.

from collections import Counter

def first_unique(s):
    counts = Counter(s)
    for i, ch in enumerate(s):
        if counts[ch] == 1:
            return i
    return -1

print(first_unique("leetcode"))      # 0  ('l')
print(first_unique("aabbcc"))        # -1

A common follow-up is a stream of characters, where you keep counts plus a queue of candidates and drop from the front of the queue whenever its count exceeds 1.

TechnicalCodingMedium

Return the k most frequent elements in an array.

Reported at Amazon, Flipkart

What they are checking: Choosing between sorting, a heap and bucket sort, and explaining the trade-offs.

Model answer

Count with a hash map, then pick the top k. Sorting all counts is O(n log n). A heap of size k is O(n log k). Bucket sort by frequency is O(n).

from collections import Counter
import heapq

def top_k(nums, k):
    counts = Counter(nums)
    return heapq.nlargest(k, counts.keys(), key=counts.get)

print(top_k([1, 1, 1, 2, 2, 3], 2))   # [1, 2]

For bucket sort, create a list of buckets where index i holds numbers that appear i times, then read from the highest bucket down until you have k numbers.

TechnicalCodingHard

Design and implement an LRU (least recently used) cache with O(1) get and put.

Reported at Amazon, Microsoft, Flipkart, Google

What they are checking: Combining data structures: a hash map for lookup and a doubly linked list for order.

Model answer

Use a hash map from key to node, plus a doubly linked list ordered by recent use. On get, move the node to the front. On put, insert at the front; if over capacity, remove the node at the back and delete its key from the map. Every operation is O(1).

In Python, OrderedDict is a hash map with a linked list inside, so it shows the idea compactly:

from collections import OrderedDict

class LRUCache:
    def __init__(self, capacity):
        self.capacity = capacity
        self.data = OrderedDict()

    def get(self, key):
        if key not in self.data:
            return -1
        self.data.move_to_end(key)
        return self.data[key]

    def put(self, key, value):
        if key in self.data:
            self.data.move_to_end(key)
        self.data[key] = value
        if len(self.data) > self.capacity:
            self.data.popitem(last=False)

Most interviewers will then ask you to write the doubly linked list yourself. Use dummy head and tail nodes so you never have to handle an empty list as a special case.

Likely follow-ups

  • Write it without OrderedDict.
  • How would you make it thread-safe?
  • How is LFU different?
TechnicalCodingHard

Numbers arrive one at a time. Return the median at any point.

Reported at Google, Amazon

What they are checking: The two-heap technique and keeping invariants.

Model answer

Keep two heaps: a max-heap for the smaller half and a min-heap for the larger half, balanced so the max-heap has the same number of elements or one more. The median is the top of the max-heap, or the average of both tops. Adding is O(log n); reading the median is O(1).

import heapq

class MedianFinder:
    def __init__(self):
        self.low = []    # max-heap, stored as negatives
        self.high = []   # min-heap

    def add(self, num):
        heapq.heappush(self.low, -num)
        heapq.heappush(self.high, -heapq.heappop(self.low))
        if len(self.high) > len(self.low):
            heapq.heappush(self.low, -heapq.heappop(self.high))

    def median(self):
        if len(self.low) > len(self.high):
            return -self.low[0]
        return (-self.low[0] + self.high[0]) / 2

Pushing into low and then moving its top to high guarantees every element in low is at most every element in high.

TechnicalMachine codingHard

Machine coding: design a parking lot system that parks and unparks vehicles and shows free slots.

Reported at Flipkart, Amazon, Microsoft

What they are checking: Can you build working, extensible, readable code in about 90 minutes? They judge class design, naming and whether it runs.

Model answer

Start by confirming requirements: multiple floors, slot types (bike, car, truck), park returns a ticket, unpark takes a ticket, and a command to show free slots per floor and type.

Core classes:

  • Vehicle (type, registration number)
  • Slot (id, floor, type, vehicle or empty)
  • Ticket (id, slot, vehicle, entry time)
  • ParkingLot (floors of slots, plus an active-tickets map)
  • A SlotAllocationStrategy interface, so "nearest free slot" can later be swapped for another rule.
from dataclasses import dataclass, field
import itertools

@dataclass
class Slot:
    floor: int
    number: int
    type: str
    vehicle: str | None = None

@dataclass
class ParkingLot:
    slots: list
    tickets: dict = field(default_factory=dict)
    _ids: itertools.count = field(default_factory=lambda: itertools.count(1))

    def park(self, reg_no, vtype):
        for slot in self.slots:            # nearest-first strategy
            if slot.type == vtype and slot.vehicle is None:
                slot.vehicle = reg_no
                ticket = f"T{next(self._ids)}"
                self.tickets[ticket] = slot
                return ticket
        return None                        # lot full for this type

    def unpark(self, ticket):
        slot = self.tickets.pop(ticket, None)
        if slot is None:
            raise ValueError("Invalid ticket")
        slot.vehicle = None
        return slot

    def free_slots(self, vtype):
        return [s for s in self.slots if s.type == vtype and s.vehicle is None]

To score well: get a working version early, then improve. Keep classes small, avoid hard-coded values, handle invalid input, and be ready to explain how you'd add pricing or a new vehicle type without rewriting existing code.

Likely follow-ups

  • Add hourly pricing.
  • How would you make free-slot lookup O(1)?
  • How would this work with multiple entry gates at once?
TechnicalSQLEasy

Write a SQL query to find the second highest salary.

Reported at TCS, Infosys, Accenture, Deloitte, Amazon

What they are checking: The most-asked SQL question. They want a correct answer and awareness of ties and NULLs.

Model answer

Subquery approach:

SELECT MAX(salary) AS second_highest
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);

Window function approach, which generalises to the Nth highest:

SELECT DISTINCT salary
FROM (
  SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rnk
  FROM employees
) ranked
WHERE rnk = 2;

DENSE_RANK matters here: if two people share the top salary, RANK would skip 2 and return nothing. The first query returns NULL when there is no second salary, which is often what the interviewer wants.

Likely follow-ups

  • Find the highest salary in each department.
  • What is the difference between RANK and DENSE_RANK?
TechnicalSQLEasy

Explain the different types of SQL joins.

Reported at TCS, Infosys, Deloitte, Amazon

What they are checking: Fundamentals, usually followed by a question on what row counts a join returns.

Model answer

Using Customers and Orders:

  • INNER JOIN: only customers who have orders, and only orders that have a matching customer.
  • LEFT JOIN: all customers, with their orders if they exist; customers without orders get NULLs. Useful for "customers who never ordered": LEFT JOIN and WHERE orders.id IS NULL.
  • RIGHT JOIN: all orders, with customer details where they exist. Rarely used; rewrite it as a LEFT JOIN.
  • FULL OUTER JOIN: all rows from both, matched where possible.
  • CROSS JOIN: every customer paired with every order; the row count is the product of both tables.
  • SELF JOIN: a table joined to itself, such as employees to their managers in the same table.

A trap: joining on a non-unique key multiplies rows. If a customer has 3 orders and 2 addresses, joining all three tables gives 6 rows for that customer, and sums will be wrong.

TechnicalSQLMedium

What is the difference between ROW_NUMBER, RANK and DENSE_RANK?

Reported at Amazon, Flipkart, Deloitte

What they are checking: Window function fluency, needed for most analyst SQL rounds.

Model answer

All three number rows in a given order; they differ only in how they handle ties. For salaries 100, 90, 90, 80:

  • ROW_NUMBER: 1, 2, 3, 4. Always unique; ties are broken arbitrarily.
  • RANK: 1, 2, 2, 4. Ties share a rank, then a gap.
  • DENSE_RANK: 1, 2, 2, 3. Ties share a rank, with no gap.

Top 3 earners in each department:

SELECT *
FROM (
  SELECT name, department, salary,
         DENSE_RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS rnk
  FROM employees
) t
WHERE rnk <= 3;

Use ROW_NUMBER when you need exactly one row per group, such as removing duplicates or picking the latest record per user.

0students
taking off