
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

Problem Model
Given coordinationThreshold[i], each robot is either Operating or Standby.
Let k be the total number of Operating robots:
- If robot
iis Operating:k - 1 >= threshold[i] - If robot
iis Standby:k < threshold[i]
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:
- For first
krobots (smaller thresholds), requiret[i] <= k - 1 - For remaining
n-krobots, requiret[i] > k
If the split is valid, that k contributes one valid configuration pattern.
Complexity
- Sorting:
O(n log n) - Sweep/validation:
O(n)orO(n log n)
Good enough for OA constraints.
Problem 2: Minimum Restock Days with Inspection and Capacity Constraints
Problem Model
tasks[i] defines daily evening action:
tasks[i] > 0: products deliveredtasks[i] < 0: products dispatchedtasks[i] = 0: inspection day (inventory must be non-negative)
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:
- Build prefix sums for baseline inventory trajectory
- Build suffix-min information for fast future-feasibility checks
- Restock only when necessary (an inspection day would become negative)
- 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:
- Translate statements into inequalities first
- Identify monotonicity / split conditions
- Then choose either “enumerate + validate” or “greedy progression”
Wrap-up
This two-question combo appears frequently in recent Amazon intern OA:
- Q1: threshold sorting + enumerate operating count
- Q2: prefix sum + suffix minima + greedy restock triggers
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