Amazon · Online Assessment

Amazon Online Assessment (OA) Guide: Coding, Work Style and Debugging Sections

What each section of the Amazon OA tests, how it is scored, three fully solved Amazon-style coding problems with dry runs, and a two-week preparation plan for SDE intern, new grad and SDE-1 candidates.

✍️ Pranjal Jain, Ex-Microsoft · IIT Kanpur 📅 10 October 2026 ⏱ 15 min read
Laptop with code and a timer surrounded by delivery boxes arranged as a graph
TL;DR
  • The Amazon OA for SDE intern, new grad and many SDE-1 roles commonly has 2 coding problems plus a work style assessment, and sometimes a work simulation. Older or role-specific versions add a debugging or reasoning section.
  • Coding problems are typically LeetCode medium level, often wrapped in an Amazon story (packages, warehouses, servers). Common patterns: greedy + sorting, heaps, BFS/DFS, sliding window, hashing, prefix sums, and DP.
  • You're scored on hidden test cases. An O(n²) solution on n = 10⁵ will time out, so read constraints first.
  • The work style section maps to Amazon's Leadership Principles. Answer honestly and consistently.
  • Formats change. Treat everything here as the commonly reported pattern and follow the instructions in your own invite.

For most candidates, the Amazon online assessment is the real gate. Amazon receives far more applications than it can interview, so the OA filters the pool down before a recruiter schedules anything. Clear it and you're in the interview loop; fail it and you'll usually wait months to try again.

This guide breaks down each section of the OA as it is commonly reported for SDE roles in India, solves three Amazon-style problems end to end in C++ and Python with dry runs, explains the debugging and work style sections, and closes with a two-week plan and what happens after you submit. For the full interview loop that follows, see our Amazon India SDE interview guide.

Amazon OA Structure: Sections and Timing

Amazon has changed its OA format several times, and it differs between internship, new-grad and experienced SDE roles. Here is the structure most commonly reported by candidates in recent cycles. Use your invite email as the source of truth; it lists the sections and time limits.

SectionWhat it isTypical length (reported)Who gets it
Coding2 algorithmic problems in an online editor with hidden test casesOften around 70–90 minutes for bothAlmost all SDE candidates
Approach explanationShort text answer on your approach and time/space complexity (in some versions)A few minutes per problemSome versions
Work simulationScenario-based questions set in a simulated day at Amazon; choose how to respond to emails, tasks and trade-offsRoughly 15–30 minutesMany new-grad and SDE-1 OAs
Work style assessmentPersonality-style statements mapped to Leadership PrinciplesRoughly 10–20 minutesMost candidates
DebuggingFix small bugs in given functions (C, C++ or Java)Short, timedOlder intern/new-grad versions; some current variants
Logical reasoningPattern and reasoning MCQsShort, timedOlder versions; occasionally reported
⚠️
Read your invite closelySome sections are separately timed and can't be paused once started. Some invites give you a window of several days to start; once you click start, the clock runs. Do the OA when you have an uninterrupted block, a stable connection and a charged laptop.

The Coding Section: Difficulty, Topics and Scoring

The two coding problems are usually LeetCode medium in difficulty, with an occasional easy or hard. They're typically framed as Amazon scenarios: packages and delivery trucks, warehouse grids, server logs, product recommendations, Prime Video watch history. Underneath the story, they map to standard patterns.

PatternHow it shows up in an Amazon storyOur deep dive
Greedy + sortingPair packages into trips, schedule deliveries, minimise trucksGreedy problems
Heaps / priority queueMerge files cheaply, top-k products, k closest warehousesHeap problems
BFS / DFS on grids and graphsRobot in a warehouse, connected server clusters, shortest delivery routeGraph BFS/DFS
Sliding window / two pointersLongest period of stable prices, sub-arrays of orders within a budgetSliding window
Hashing and countingDuplicate orders, frequency of search terms, anagram product codesHashing
Prefix sumsRange totals over daily sales, balanced partitionsPrefix sums
Dynamic programmingWays to assemble shipments, minimum cost to process itemsDP questions

How scoring works

Your code runs against a set of hidden test cases, some small and some at the maximum constraints. Each passed case earns credit. Amazon doesn't publish a pass mark. Candidates commonly report moving forward after passing all or nearly all cases on both problems, and being rejected with weak results on one. Practically, that means:

  • An efficient, correct solution on both problems is the target.
  • If you're stuck on the optimal approach, submitting a correct brute force earns the small-input cases. Partial credit beats zero.
  • Edge cases (empty input, single element, all equal, maximum values causing overflow) are where many hidden cases live.

Below are three original Amazon-style problems that cover the most common patterns. Each has a story, constraints, the insight, code in C++ and Python, a dry run and complexity.

Problem 1: Minimum Delivery Trips (Greedy + Two Pointers)

Problem. A delivery van can carry at most two packages per trip, and their combined weight must not exceed limit. Given n package weights (each ≤ limit), return the minimum number of trips to deliver all of them. Constraints: 1 ≤ n ≤ 10⁵, 1 ≤ weight ≤ limit ≤ 10⁹.

Insight

Sort the weights. The heaviest package must go on some trip. The best partner for it is the lightest remaining package: if even the lightest can't fit with it, nothing can, so the heaviest goes alone. If the lightest does fit, pairing them never hurts, because any other partner would be heavier and leave a worse set behind (a standard exchange argument). Two pointers, one at each end, implement this.

C++
int minTrips(vector<int> w, int limit) {
    sort(w.begin(), w.end());
    int i = 0, j = (int)w.size() - 1, trips = 0;
    while (i <= j) {
        if (i < j && w[i] + w[j] <= limit) i++;  // lightest rides with heaviest
        j--;                                    // heaviest always leaves
        trips++;
    }
    return trips;
}
Python
def min_trips(weights, limit):
    w = sorted(weights)
    i, j, trips = 0, len(w) - 1, 0
    while i <= j:
        if i < j and w[i] + w[j] <= limit:
            i += 1
        j -= 1
        trips += 1
    return trips

Dry run

Input: weights = [70, 50, 80, 50], limit = 100. Sorted: [50, 50, 70, 80].

ijw[i] + w[j]Actiontrips
0350 + 80 = 130 > 10080 goes alone, j → 21
0250 + 70 = 120 > 10070 goes alone, j → 12
0150 + 50 = 100 ≤ 100pair them, i → 1, j → 03

Loop ends (i = 1 > j = 0). Answer: 3.

Complexity: O(n log n) time for sorting, O(1) extra space beyond the sort (O(n) in Python because sorted copies). The i < j check matters: without it, when one package remains, the code would compare it with itself.

Problem 2: Minimum Cost to Merge Files (Min-Heap)

Problem. An Amazon service must merge n log files into one. Merging two files of sizes a and b costs a + b and produces a file of size a + b. Return the minimum total cost. Constraints: 1 ≤ n ≤ 10⁵, 1 ≤ size ≤ 10⁹.

Insight

Every file's size is added to the total once for each merge it participates in, so large files should be merged as few times as possible, i.e. as late as possible. Repeatedly merging the two smallest files is optimal (the same argument as Huffman coding). A min-heap gives the two smallest in O(log n) each.

Watch the numbers: with n = 10⁵ files of size 10⁹, the total cost far exceeds 2³¹. Use long long in C++ (or long in Java). Overflow here is one of the most common reasons for failing hidden test cases.

C++
long long minMergeCost(const vector<int>& files) {
    priority_queue<long long, vector<long long>, greater<long long>> pq(files.begin(), files.end());
    long long cost = 0;
    while (pq.size() > 1) {
        long long a = pq.top(); pq.pop();
        long long b = pq.top(); pq.pop();
        cost += a + b;
        pq.push(a + b);
    }
    return cost;
}
Python
import heapq

def min_merge_cost(files):
    heap = list(files)
    heapq.heapify(heap)          # O(n)
    cost = 0
    while len(heap) > 1:
        a = heapq.heappop(heap)
        b = heapq.heappop(heap)
        cost += a + b
        heapq.heappush(heap, a + b)
    return cost

Dry run

Input: [8, 4, 6, 12].

StepHeap beforeMergeStep costTotal
1{4, 6, 8, 12}4 + 6 = 101010
2{8, 10, 12}8 + 10 = 181828
3{12, 18}12 + 18 = 303058

Answer: 58. Compare a naive left-to-right order (8+4=12, 12+6=18, 18+12=30, total 60) to see why order matters.

Complexity: O(n log n) time, O(n) space. With n = 1, the loop never runs and the cost is 0, which is correct.

Problem 3: Warehouse Robot Shortest Path (Grid BFS)

Problem. A robot starts at the top-left cell of an R × C warehouse grid. Cells are 1 (free), 0 (blocked shelf) or 9 (the target shelf, reachable). The robot moves up, down, left or right. Return the minimum number of moves to reach the target, or -1 if it can't. Constraints: 1 ≤ R, C ≤ 1000.

Insight

Every move costs 1, so breadth-first search finds the shortest path: BFS visits cells in order of distance from the start. Mark cells visited when you push them, not when you pop them; otherwise the same cell can be queued many times and a 10⁶-cell grid can time out or run out of memory.

C++
int shortestPath(const vector<vector<int>>& g) {
    int R = g.size(), C = g[0].size();
    if (g[0][0] == 0) return -1;
    vector<vector<int>> dist(R, vector<int>(C, -1));
    queue<pair<int,int>> q;
    q.push({0, 0});
    dist[0][0] = 0;
    int dr[] = {1, -1, 0, 0}, dc[] = {0, 0, 1, -1};
    while (!q.empty()) {
        int r = q.front().first, c = q.front().second; q.pop();
        if (g[r][c] == 9) return dist[r][c];
        for (int k = 0; k < 4; k++) {
            int nr = r + dr[k], nc = c + dc[k];
            if (nr < 0 || nc < 0 || nr >= R || nc >= C) continue;
            if (g[nr][nc] == 0 || dist[nr][nc] != -1) continue;
            dist[nr][nc] = dist[r][c] + 1;   // mark on push
            q.push({nr, nc});
        }
    }
    return -1;
}
Python
from collections import deque

def shortest_path(grid):
    rows, cols = len(grid), len(grid[0])
    if grid[0][0] == 0:
        return -1
    dist = [[-1] * cols for _ in range(rows)]
    dist[0][0] = 0
    q = deque([(0, 0)])
    while q:
        r, c = q.popleft()
        if grid[r][c] == 9:
            return dist[r][c]
        for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            nr, nc = r + dr, c + dc
            if 0 <= nr < rows and 0 <= nc < cols and grid[nr][nc] != 0 and dist[nr][nc] == -1:
                dist[nr][nc] = dist[r][c] + 1
                q.append((nr, nc))
    return -1

Dry run

grid: distances found by BFS: 1 1 1 1 0 1 2 3 0 1 0 1 . 2 . 4 1 1 0 9 4 3 . 5

BFS expands distance 0 → (0,0); distance 1 → (0,1); distance 2 → (0,2), (1,1); distance 3 → (0,3), (2,1); distance 4 → (1,3), (2,0); distance 5 → (2,3), which is the target 9. Answer: 5. If the target were walled off, the queue would empty and we'd return -1.

Complexity: O(R × C) time and space; each cell is pushed at most once and checks four neighbours. Use deque in Python, never list.pop(0), which is O(n) per pop.

💡
Translate the story firstBefore writing any code, rewrite the problem in one sentence of plain CS: "sort and pair from both ends", "repeatedly combine two smallest", "shortest path in an unweighted grid". If you can't, re-read the constraints; they often reveal the intended complexity.

The Debugging Section: How to Approach It

Where it appears, the debugging section gives you short functions (often in C, C++ or Java) that contain one bug each, usually a logic or boundary error rather than a syntax error. You get a fixed time for several snippets, so speed matters. Typical bug types:

  • Off-by-one in loop bounds (<= vs <, starting at 1 instead of 0).
  • Wrong comparison operator (> instead of < in a sort or max/min).
  • Wrong variable used (i instead of j), or a variable not reset inside a loop.
  • Integer division or overflow issues.
  • Wrong return value (returning a counter instead of the result).

Example

The function should count pairs (i, j) with i < j and a[i] + a[j] == target:

Java (buggy)
int countPairs(int[] a, int target) {
    int count = 0;
    for (int i = 0; i < a.length; i++) {
        for (int j = 0; j < a.length; j++) {
            if (a[i] + a[j] == target) count++;
        }
    }
    return count;
}

The bug: the inner loop starts at 0, so it counts each pair twice and pairs an element with itself. The fix is one token: int j = i + 1. Debugging questions are usually like this, where the fix is small and the skill is spotting it fast.

Method: read the function's stated purpose, run a tiny example by hand (2–3 elements), and compare against expected output. Most bugs reveal themselves on a 3-element dry run within a minute.

The Work Style Survey and Work Simulation

Work style assessment

You'll see statements about how you work and choose how strongly you agree, or pick the statement from a pair that describes you better. The assessment maps to Amazon's Leadership Principles, such as Customer Obsession, Ownership, Bias for Action, Dive Deep, Deliver Results and Earn Trust.

Guidance that holds up:

  • Read the Leadership Principles before the OA. Not to game the survey, but to understand what kinds of behaviour Amazon values. You'll need them for the interviews anyway.
  • Answer honestly and consistently. Similar ideas are asked in different ways. Wildly inconsistent answers can look worse than honest moderate ones.
  • Don't overthink. Go with your considered first instinct; the section is timed.

Work simulation

The work simulation puts you in a realistic scenario, for example a day on a software team, with messages from a manager or teammates, a customer-impacting issue, a deadline. You choose or rank responses. It tests judgment: do you prioritise customer impact, gather data before acting, communicate proactively, take ownership instead of escalating everything?

A useful lens for each scenario: What does the customer need? What's the fastest responsible action? Who needs to know? Options that ignore customer impact, hide problems or wait passively for instructions are usually the weaker choices. Options that act reasonably fast on available data while keeping stakeholders informed usually reflect Amazon's principles.

A Two-Week Amazon OA Preparation Plan

If you already know basic DSA and your OA link has just arrived (or is expected soon), this plan focuses on the patterns and conditions of the OA itself.

  1. Days 1–3: Greedy, sorting, two pointers, hashing. 4–5 medium problems a day. For each, write the one-line insight and the complexity before coding.
  2. Days 4–6: Heaps and intervals. Top-k, merge-k, scheduling with priority queues, interval merging. Practise writing heap comparators quickly in your language.
  3. Days 7–9: Graphs and grids. BFS shortest path, connected components, multi-source BFS, topological sort. Write BFS from scratch each time until it takes under 3 minutes.
  4. Days 10–11: Sliding window, prefix sums and basic DP. These appear often enough that you shouldn't skip them.
  5. Days 12–13: Timed mocks. Two full simulations: two problems in about 70–90 minutes on a HackerRank-style editor, with no IDE autocomplete. Review every failed edge case.
  6. Day 14: Leadership Principles and logistics. Read the principles; skim your mock mistakes; test your laptop, internet, and the platform's sample test if provided.

Our general guide to clearing online coding assessments covers the editor, I/O handling, partial-score strategy and proctoring rules in more depth.

During the OA: a time plan

First 5 min

Read both problems

Note constraints. Decide which is easier and start there.

Next ~30 min

Solve the easier one fully

Optimal approach, edge cases, test with custom input, submit.

Next ~35 min

Solve the harder one

If the optimal approach isn't clear after 10 minutes, submit a correct brute force, then optimise.

Last ~10 min

Edge cases and overflow

Empty input, single element, large values. Resubmit if needed.

What Happens After the Amazon OA

After you submit, outcomes typically fall into three buckets:

  • Cleared: a recruiter emails to schedule interviews. For SDE-1 and new-grad roles in India, candidates commonly report a few rounds (often around three), sometimes as a single-day virtual loop. Each round mixes coding with Leadership Principles questions, and a bar raiser may be one of the interviewers.
  • Not cleared: usually an automated email. Candidates commonly report a cooling-off period, often around six months, before reapplying for similar roles; confirm with the recruiter.
  • Silence: timelines vary from days to several weeks depending on hiring volume. A polite follow-up to the recruiter after two to three weeks is fine.

Preparing for the interviews while you wait

Don't wait for the result to start interview prep. The loop typically includes coding problems similar to OA difficulty, plus behavioural questions where you're expected to answer with specific stories mapped to Leadership Principles. Prepare 8–10 STAR stories (ownership, disagreement, failure, tight deadline, customer impact, diving deep into a bug). Our guide to the STAR method shows how to structure them, and the Amazon interview preparation guide covers the loop round by round.

✅
One more thing to prepareInterviewers sometimes ask how you solved your OA problems. Write down both problems and your solutions right after you submit, while they're fresh. Being able to discuss them, including what you'd improve, is an easy win.

The Amazon OA is very passable with focused preparation. Know the core patterns cold, practise under real time pressure, guard against overflow and edge cases, understand the Leadership Principles, and treat the work style sections with the same seriousness as the code.

Frequently Asked Questions

How many questions are in the Amazon OA?▾
The commonly reported format for SDE intern and new-grad roles is two coding problems, followed by a work style assessment and sometimes a work simulation. Older versions included a debugging section and a logical reasoning section. The exact format varies by role, region and year, so read the instructions in your invite carefully.
Which platform does Amazon use for its online assessment?▾
Amazon's coding assessments have commonly been delivered on HackerRank or through Amazon's own assessment portal with a HackerRank-style editor. You can usually pick from mainstream languages like C++, Java and Python. Your invite email will name the platform and include a practice link if one is available.
Do I need to pass all test cases in the Amazon OA?▾
Not necessarily. Scoring is based on hidden test cases, and passing most of them on both problems is often reported to be enough to move forward, but Amazon does not publish a cutoff. Aim for full correctness and an efficient solution; a brute force that times out on large inputs loses many cases.
What is the Amazon work style assessment?▾
It is a questionnaire where you choose how much you agree with statements or pick between pairs of statements about how you work. It maps to Amazon's Leadership Principles, such as Customer Obsession, Ownership and Bias for Action. Answer honestly and consistently; it is not a test you can study for, but knowing the Leadership Principles helps you understand what it measures.
Can I use any language in the Amazon OA?▾
Usually yes, among the languages the platform supports, which typically include C++, Java, Python and others. Use the language you are fastest and most accurate in. Python is concise, but C++ or Java can be safer for tight time limits on heavy computations.
How long does Amazon take to respond after the OA?▾
It varies from a few days to several weeks depending on the role, hiring volume and location. If you clear it, a recruiter typically contacts you to schedule interviews. If you have not heard back after two or three weeks, a polite email to your recruiter contact is reasonable.
Can I retake the Amazon OA if I fail?▾
Candidates commonly report a cooling-off period, often around six months, before they can be considered again for a similar role. Policies can differ by role and region, so confirm with your recruiter rather than assuming.

Clear the Amazon OA and the Loop After It

Prepflix's DSA programme drills the greedy, heap, graph and DP patterns Amazon OAs lean on, then prepares you for the Leadership Principles interviews that follow.

Explore the Prepflix Course →
Pranjal Jain
Pranjal Jain

Ex-Microsoft SDE · IIT Kanpur · Founder of Prepflix. Helps engineers crack startup and product company interviews across India.