Amazon HackerRank OA Real Question Breakdown | 2026 Amazon Online Assessment Two Coding Problems Review

1,276 Views

Recently, Amazon has once again launched a large-scale distribution of Online Assessments, with this round uniformly using the HackerRank platform. The common consensus among many students after completing them is that the questions themselves are not strictly difficult, but if there is a misunderstanding, the subsequent code is almost impossible to salvage. Today, we will systematically review two Amazon OA coding questions to help students participating in future OAs establish the right expectations in advance.

Amazon OA basic information overview

  • Test platform: HackerRank
  • 题目数量:2 道 Coding
  • Overall difficulty: above average
  • Main inspection capabilities:
    • Fast abstraction of complex business rules
    • Ability to use dynamic data structures
    • Is the greedy strategy reasonable?
    • Sensitivity to hidden constraints and boundary conditions

Question 1: Server allocation and cost calculation issues

Question background

There are several servers in the system, and each server has a certain number of idle instances. The server status is given in the form of an array, the array subscript represents the server number, and the value represents the current number of available instances.

Now there are m customers arriving one after another, and each customer needs to choose a server to rent an instance. The status of the server changes continuously as the client makes choices.

Allocation and Cost Rules

For each customer, the system will perform the following operations:

  1. Among all current servers, select the server with the largest number of idle instances
  2. After a successful selection, the number of idle instances of the server is reduced by 1
  3. This selection will generate a cost, which is calculated as:
    • cost = the minimum number of idle instances in all current servers before selection + the maximum number of idle instances

Final required output: the cumulative sum of all costs after m customers have completed allocation.

Analysis of the essence of problem solving

This is a very typical Amazon-style question. The essence is not to test complex algorithms, but to test whether the candidate can:

  • Quickly identify that this is a problem of dynamically maintaining maximum and minimum values
  • In multiple update scenarios, avoid using inefficient full array scans

During ProgramHelp’s coaching process, the main reasons for losing points on this question focus on three aspects:

  1. Didn't realize that cost must be calculated "before selection"
  2. Each round traverses the array to find the maximum/minimum value, resulting in excessive time complexity.
  3. Not properly handling the server status after the number of instances is reduced to 0

Correct solution direction

The standard solution to this type of problem is to use a heap structure to maintain server state:

  • Use the maximum heap to dynamically maintain the server with the most idle instances currently
  • At the same time maintain the current minimum idle instance value (can be through the minimum heap or additional counting structure)

Each round of operations only requires:

  • Take the maximum value
  • Record the current maximum and minimum
  • Update server status and re-enter the heap

As long as the data structure is chosen correctly, the overall implementation is stable and controllable.

Question 2: Log Parts and Warehouses Allocation Maximization Problem

Question background

There are multiple log delivery in the system, and each log corresponds to a certain number of parts. There are now k warehouses, where k is an even number.

The storage rules are as follows:

  • Each warehouse can only store data from Same log Parts
  • Parts of the same log can be distributed and stored in multiple warehouses
  • Parts that are allowed to have partial logs are ultimately not stored in any warehouse.

Sorting and target constraints

When all warehouses have completed storage:

  • Sort by the number of parts stored in each warehouse
  • The top k/2 warehouses are considered the "half with the most storage"
  • The warehouse ranked after k/2 is considered the "half with the least storage"

The question requires output:
The maximum possible value of the sum of the number of parts in the second half (k/2 warehouses with the least storage).

Core difficulties in problem solving

The difficulty of this question is not in the implementation, but in the understanding of the goal.

Many students will subconsciously want to "store as many parts as possible", but the real optimization goal is not the total storage amount, but:

After sorting, try to raise the sum of the second half of the warehouse as much as possible.

This means that the first half of the warehouses must not consume too many components; the allocation strategy needs to be as balanced as possible, while also satisfying the constraint that each individual warehouse can only receive components from a single log.

Why do many Amazon OAs choose professional assistance?

In real cases at ProgramHelp, many candidates’ issues are not that they “can’t write the solution at all,” but rather that OA time is tight, there’s no room for trial and error, the problem rules are complex and easy to trip over on details, and the platform constraints are strict—one mistake can lead to immediate elimination.

The essence of the Amazon OA is candidate screening rather than teaching. In this context, choosing stable and experienced interview support is often more effective than simply “doing a few more practice problems.”

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END
 0