← 返回博客列表
Amazon

Amazon Intern OA Recap: Robot Threshold Configurations + Minimum Emergency Restock Days

2026-03-23

Amazon OA Code Question 1

Recently, these two-problem OA sets have shown up frequently for Amazon intern roles. Here is a practical breakdown of both problems and the core approach for each.


Problem 1: Count Stable Robot Configurations by Threshold

Amazon OA Code Question 2

Problem Model

Given coordinationThreshold[i], each robot is either Operating or Standby.

Let k be the total number of Operating robots:

Count the number of distinct state assignments with no malfunction.

Key Insight

Brute force over all assignments (2^n) is too expensive.

The structure is monotonic: once k is fixed, eligibility is mostly determined by thresholds. So we can enumerate k = 0..n and validate feasibility.

Sorted Validation Logic

Sort thresholds ascending as t[0..n-1].

If exactly k robots are Operating:

If the split is valid, that k contributes one valid configuration pattern.

Complexity

Good enough for OA constraints.


Problem 2: Minimum Restock Days with Inspection and Capacity Constraints

Problem Model

tasks[i] defines daily evening action:

Each morning, emergency restock is allowed (any amount), but inventory can never exceed max_products on any day. Return minimum number of restock days, or -1 if impossible.

Core Approach

Treat emergency restock as a monotone non-decreasing adjustment variable and use each restock as far as possible.

Typical implementation strategy:

  1. Build prefix sums for baseline inventory trajectory
  2. Build suffix-min information for fast future-feasibility checks
  3. Restock only when necessary (an inspection day would become negative)
  4. When restocking, greedily push to the maximum safe level under capacity constraints to cover more future checks

Why Greedy Works

Objective is minimizing number of restock days, not total restock volume.

So when a restock is triggered, maximizing its forward coverage is the right local choice and leads to fewer future interventions.

Complexity

Using prefix sums + suffix minima, this is typically linear / near-linear and OA-friendly.


Practical Notes for Amazon Intern OA

Both problems emphasize modeling over heavy coding:


Wrap-up

This two-question combo appears frequently in recent Amazon intern OA:

If you're preparing now, mastering these two patterns has strong ROI.


💬 Need OA/VO Discussion Support?

Current interview patterns for Amazon, Google, TikTok, Microsoft, Meta, Uber are being continuously organized.
If you have uncertainty on recent OA/VO questions, feel free to ask.

WeChat: Coding0201