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

161 Views
No Comment

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
  • Number of questions: 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

第一题:服务器分配与 Cost 计算问题

Question

系统中存在若干台服务器,每台服务器拥有一定数量的空闲实例。服务器状态以数组形式给出,数组下标代表服务器编号,数值代表当前可用实例数量。

现在有 m 位客户依次到来,每一位客户都需要选择一台服务器租用一个实例。服务器的状态会随着客户的选择不断发生变化。

分配与 Cost 规则

对每一位客户,系统会执行如下操作:

  1. 在当前所有服务器中,选择 空闲实例数量最多 的服务器
  2. 成功选择后,该服务器的空闲实例数量减 1
  3. 本次选择会产生一个 cost,其计算方式为:
    • cost = 选择前,当前所有服务器中的最小空闲实例数 + 最大空闲实例数

最终要求输出:在 m 位客户完成分配之后,所有 cost 的累计总和。

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.

第二题:Log 零件与 Warehouses 分配最大化问题

Question

系统中存在多个 log delivery,每个 log 对应一定数量的零件(parts)。现在有 k 个 warehouses,其中 k 为偶数。

存储规则如下:

  • 每个 warehouse 只能存储来自 Same log Parts
  • 同一个 log 的零件可以被分散存储到多个 warehouse
  • 允许存在部分 log 的零件最终未被任何 warehouse 存储

排序与目标约束

当所有 warehouse 完成存储后:

  • 按照每个 warehouse 存储的零件数量进行排序
  • 排名前 k/2 的 warehouse 被认为是“存储最多的一半”
  • 排名后 k/2 的 warehouse 被认为是“存储最少的一半”

题目要求输出:
后半部分(存储最少的 k/2 个 warehouse)中,零件数量之和的最大可能值。

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