Stable Robot Configurations
Learn this problemProblem statement
In Amazon's warehouse robotics system, multiple robots operate simultaneously to transport packages efficiently. Each robot can be in one of two states: Standby or Operating.
For smooth coordination, each robot i has a predefined coordination threshold, coordinationThreshold[i]. This threshold determines the conditions under which a robot malfunctions:
- A robot
imalfunctions if it is in theOperatingstate but the total number of other robots in theOperatingstate is less thancoordinationThreshold[i]. - A robot
imalfunctions if it is in theStandbystate but the total number of robots in theOperatingstate is greater than or equal tocoordinationThreshold[i].
If any robot malfunctions, the system is considered unstable. Return the total number of distinct valid configurations where no robot malfunctions.
A configuration is an assignment of each of the n robots to either Operating or Standby. A configuration is considered valid if no robot malfunctions under that arrangement. Two configurations are distinct if at least one robot is in a different state.
Function
countStableConfigurations(coordinationThreshold: int[]) → intExamples
Example 1
coordinationThreshold = [6, 0, 3, 3, 6, 7, 2, 7]return = 3There are three valid ways to select robots to be in the Operating state. The source explanation shows these two:
- Only the robot at index
1isOperating. Its threshold is0, so it has at least0other operating robots. All other robots remain inStandby, and their thresholds exceed the one operating robot. - Robots at indices
1,2,3, and6areOperating, with threshold values0,3,3, and2. Each operating robot has at least its threshold number of other operating robots, and every standby robot has fewer operating robots than its threshold.
So the total number of valid configurations is 3.
More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026