Maximum Robots Retired From Shared Rows or Columns

Last updated: November 29, 2026

Quick Overview

Warehouse robots park at distinct grid cells; a robot may be retired if another active robot shares its row or column. Return the maximum number of robots that can be retired one after another.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Warehouse robots park at distinct grid cells; a robot may be retired if another active robot shares its row or column. Return the maximum number of robots that can be retired one after another.

A union find question in the style of Amazon Robotics fleet consolidation. The interviewer looks for the insight that each connected group (robots linked through shared rows or columns) can be reduced to one robot, so the answer is robots minus components.

What the Interviewer Expects
  • Connect robots that share a row or a column
  • Prove each component can be reduced to exactly one robot
  • Union row nodes with column nodes to avoid O(n^2) pair checks
  • Count components over rows used
  • O(n alpha(n)) time
Key Topics to Cover
union find
connected components
bipartite modeling
grid
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Show the retirement order for a component (hint: reverse DFS post-order).
  • What if each retirement has a cost?
  • What if robots can move before retiring?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of distinct (row, col) positions. A retirement requires another still-active robot in the same row or column. Output: max retirements....

High-Level Design

Build a graph where robots sharing a row or column are adjacent. In any connected component of size k, we can retire k - 1 robots: do a DFS from any robot and retire robots in reverse discovery order,...


Submit Your Answer
Markdown supported