Amazon HackerRank Assessment: SDE Coding Practice & Prep

Prepare for an Amazon HackerRank coding assessment: check your SDE format, try two original Python exercises, and diagnose hidden-test failures.

EmmaEmmaArticle Editing & Website Operations
Nov 9, 2026AmazonUS SDE Applicants
AI-generated editorial illustration of Amazon HackerRank coding practice with a laptop, workload blocks and test cases

Cover: AI-generated editorial illustration.

An Amazon HackerRank assessment can mean different things for different jobs. This guide is for software development engineer (SDE) applicants preparing for a coding assessment. Amazon's SDE II preparation page describes two coding questions in 90 minutes and recommends getting comfortable with HackerRank. Student and graduate applicants have a separate preparation route.

If your invitation names SQL, a Business Intelligence Engineer role, or a different specialist assessment, use the instructions for that role. The Python exercises below address algorithmic coding, not SQL preparation.

Start here: identify your assessment, try the two exercises without solutions, then use the failure checklist to decide what to practice next.

Sources checked November 9, 2026. This is a research-based guide edited with AI assistance. SkillCopilotAI sells an interview assistant. We did not take an Amazon hiring assessment. The two exercises are original teaching material; their Python solutions were checked locally against independent reference implementations. They are not reported Amazon questions or predictions of your test.

Find the part you need

Which Amazon HackerRank assessment are you preparing for?

Open the invitation and record the job title, level, deadline with time zone, section names, and coding time limit. The coding timer and the whole assessment are different things.

Applicant routeWhat Amazon's public guidance supportsWhat to confirm before preparing
Student or graduate SDE, including internshipsThe university page lists a coding component averaging 70 minutes and work-style questions; its full-time route also lists a work simulationYour assigned sections, time allowance and whether the OA is split into parts
SDE IIThe dedicated OA page describes two coding questions in 90 minutes, plus system-design and work-style sectionsYour invitation's actual configuration and required completion steps
SQL or another specialist trackThis article does not establish that track's formatRequired language, question types and role-specific preparation materials

Use Amazon's university SDE OA page for the student route and its SDE II OA page for experienced SDE II preparation. Do not transfer a 70-minute practice schedule, a SQL candidate's account, or a test-case count to every Amazon application.

For platform familiarization, follow the Practice Test link on Amazon's university page. Amazon describes it as unscored practice with two questions. HackerRank's before-test FAQ also explains sample tests. Use the practice link attached to your actual invitation when available; an old indexed contest is not a replacement for it.

What do candidate reports tell you to practice?

Reports are useful for identifying skills and difficulties. They cannot tell you which questions your invitation contains.

Public accountUseful preparation signalWhat it does not establish
An SDE 1 candidate's Reddit discussion describes a last-second submission followed by uncertainty about whether a fix was receivedRehearse running and submitting a working version before the final secondsA guaranteed submission outcome, passing score or extra grace period
Alim Mohammad's LinkedIn account mentions sliding-window and greedy problems in an OAPractise deriving an algorithm from constraints and explaining its invariantUS-wide question frequency; the visible account does not establish a US location

Those accounts are self-reported and were not independently reproduced. The exercises below train frequency counting and capacity search, two reusable techniques. They are selected teaching examples, not a ranked list of Amazon's most frequent questions.

Two original exercises for coding preparation

Use your intended test language for practice. The worked answers use Python 3. Before expanding a solution, write down the input contract, one manual example, the simplest correct approach, and the cost of that approach at the maximum input size.

Exercise 1: Count account participation in event logs

Each event is a pair of positive integer account IDs, (sender, recipient). An account participates once in that event even when both IDs are the same. Repeated pairs represent separate events and must each be counted.

Return the IDs participating in at least threshold events, sorted numerically. There may be zero to 200,000 events; threshold is a positive integer.

For events = [(7, 7), (7, 12), (12, 7), (40, 12)] and threshold = 3, return [7, 12]. Account 7 appears in the first three events, account 12 in the last three, and account 40 only once.

Try it first. What changes if you count both positions of (7, 7)?

Show hint, Python solution and self-checks

Maintain one counter per account. Increment the sender, then increment the recipient only when it differs. You need event participation, not the number of ID fields.

def active_accounts(events, threshold):
    counts = {}
    for sender, recipient in events:
        counts[sender] = counts.get(sender, 0) + 1
        if recipient != sender:
            counts[recipient] = counts.get(recipient, 0) + 1
    return sorted(
        account for account, count in counts.items()
        if count >= threshold
    )

Let n be the number of events and u the number of distinct accounts. Counting takes expected O(n) time with a hash map, and sorting the qualifying IDs takes at most O(u log u). Extra space is O(u).

Self-checkExpected resultMistake it catches
active_accounts([], 1)[]Assuming at least one event
active_accounts([(7, 7)], 2)[]Counting a self-event twice
active_accounts([(2, 10), (2, 10)], 2)[2, 10]Deduplicating separate events or sorting IDs as strings
active_accounts([(1, 2)], 3)[]Including accounts below the threshold

The tempting shortcut is to convert the entire input to a set. That removes repeated events and changes the question. Only deduplicate the two participants within one event.

Exercise 2: Minimize the largest contiguous batch

A queue contains loads, a nonempty list of nonnegative integer job sizes. Split it into at most k nonempty contiguous batches, keeping the original order. Return the smallest possible value of the largest batch sum.

Assume 1 <= k <= len(loads), at most 200,000 jobs, and each size at most one billion. Jobs cannot be split or reordered.

For loads = [4, 1, 7, 3, 2] and k = 2, return 12. The split [4, 1] and [7, 3, 2] gives sums 5 and 12. The four possible two-batch splits have maximum sums 13, 12, 12 and 15, so a capacity of 11 cannot work.

Show hint, Python solution and self-checks

For a proposed capacity, greedily extend the current batch until the next job would exceed it. Then start another batch. With nonnegative sizes, extending a batch cannot reduce its sum, so this uses the fewest batches possible for that capacity.

Feasibility is monotonic: if a capacity works, every larger capacity works. Binary-search between the largest individual load and the sum of all loads.

def minimum_batch_capacity(loads, k):
    low, high = max(loads), sum(loads)
    while low < high:
        capacity = (low + high) // 2
        batches, current = 1, 0
        for load in loads:
            if current + load > capacity:
                batches += 1
                current = 0
            current += load
        if batches <= k:
            high = capacity
        else:
            low = capacity + 1
    return low

If S is the total load, time is O(n log(S + 1)), with O(1) extra working space. The all-zero case returns zero without entering the search loop. In languages with fixed-width integers, use a type wide enough for the total load and midpoint arithmetic.

Self-checkExpected resultMistake it catches
minimum_batch_capacity([0, 0], 2)0Mishandling zero-sized jobs
minimum_batch_capacity([4, 1, 7, 3, 2], 1)17Forgetting the single-batch case
minimum_batch_capacity([4, 1, 7, 3, 2], 5)7Returning less than the largest job
minimum_batch_capacity([6, 1, 1, 6], 2)7Reordering instead of preserving contiguous groups

Do not sort loads before searching. Sorting changes which jobs are adjacent. Explain why the greedy feasibility check relies on nonnegative inputs; the same argument does not automatically work with negative job sizes.

Why do samples pass but hidden tests fail?

HackerRank's hidden-test documentation explains that unseen cases check constraints and corner scenarios. Its evaluation guide also warns that correct logic can fail when output formatting differs.

Use the observed failure to choose a smaller experiment:

SymptomCheck nextA useful experiment
Wrong answer on a tiny caseThe exact counting, ordering or boundary ruleIn exercise 1, try one self-event and two identical events separately
Wrong answer only after optimizationThe invariant that makes the shortcut validCompare the optimized result with a slow reference on small inputs
Time limit exceededRepeated scanning, sorting or nested loops at the input limitCount operations before assuming your language is too slow
Runtime errorEmpty input where allowed, indexing, recursion depth or integer rangeTest the smallest valid input and the largest total value
Correct local result, rejected outputThe provided function signature and return/print contractRemove debug output and match the requested type and order

Do not invent hidden answers. Reduce the problem until you can calculate an expected result yourself. A short counterexample usually tells you more than another random large test.

There is no fixed number of hidden cases or universal Amazon passing threshold established here. HackerRank's evaluation-method overview describes summing passed-case scores. A raw fraction of cases is not necessarily the same as a percentage of available points or a hiring decision.

How to use one practice session

Try this suggested 60-minute training block, independently of your actual OA timer:

  1. First 5 minutes: copy the input contracts and predict the example outputs yourself.
  2. Next 15 minutes: attempt the event-counting problem without opening its solution.
  3. Next 25 minutes: attempt the capacity problem. Write the feasibility condition before the binary search.
  4. Final 15 minutes: compare with the answers, run the self-checks, and record the smallest case that exposed each mistake.

After reviewing, close the solutions and explain each approach aloud: what state it maintains, why it is correct, what it costs, and when it would stop working. If you cannot explain why self-events count once or why capacity feasibility is monotonic, repeat that point before adding more questions.

You can use a practice assistant before the assessment to challenge your explanation. A useful prompt is: “Ask me one question about the invariant in this original exercise. Wait for my answer, then identify a concrete weakness.” Verify the feedback against the specification and tests. Our AI interview assistant selection guide can help if you are deciding whether a tool fits that preparation task. It is optional; both exercises can be completed without one.

Before starting your actual assessment

Check rules for the assessment you have, not the platform name alone. Amazon's university guidance allows certain public references, logs browser usage, asks candidates to avoid copy-paste, and warns against print-screen use. That is not blanket permission for an external AI assistant. If a task provides an approved built-in assistant, follow its stated scope; do not assume permission extends to other tools.

Use the public practice environment to check the editor, language and input format. Do not start a scored invitation just to inspect it or collect screenshots. Camera, identity and workspace requirements must come from your own setup instructions.

Re-run and submit after a fix. HackerRank's submission instructions distinguish an auto-saved draft, a code run and a submission. Leave time to compile, inspect the result and submit the version you intend to send. If something fails, note the error text, time, job ID and affected section, then contact the recruiting or support contact in your invitation.

After coding, check for any remaining assigned sections and the completion confirmation. The university page explains how to contact recruiting if a two-part completion email is missing after 24 hours. For results or a deadline extension, use your recruiting contact rather than assuming a forum's timing or score applies to you.

For broader platform setup and practice guidance, continue with our HackerRank OA preparation guide. Keep your next action specific: fix a known coding weakness, complete the correct practice entry, or resolve an unclear invitation before its deadline.

Ready to ace your next technical interview?

Practice interview questions, review your explanations, and explore SkillCopilotAI for interview preparation.