Find bounding boxes of connected houses
Company: Rippling
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
You are given a 2D grid representing a map, where each cell is either `1` (part of a house) or `*` (empty). A **house** is a maximal group of `1` cells connected **4-directionally** (up, down, left, right).
Unlike a standard matrix, the grid is **ragged**: each row may have a different number of columns.
### Task
Return the bounding rectangle of every house as a pair:
- **top-left** coordinate (minimum row, minimum column among the house’s cells)
- **bottom-right** coordinate (maximum row, maximum column among the house’s cells)
Coordinates must be formatted like spreadsheet cells:
- Rows are labeled with uppercase letters: `A` for row 0, `B` for row 1, …
- Columns are labeled with 1-based numbers: column 0 → `1`, column 1 → `2`, …
So row `0`, col `1` is `A2`.
### Input
- A list of rows, where each row is a list (or string) of characters from `{ '1', '*' }`.
- Rows can have different lengths.
### Output
- A list of house bounding boxes, each represented as a pair of strings: `[topLeft, bottomRight]`.
- The order of houses may be arbitrary unless otherwise specified.
### Example
Grid (ragged):
- Row A: `[* * * * 1 1 1 * *]`
- Row B: `[* 1 1 * *]`
- Row C: `[* * 1 1 * * *]`
Interpretation: a cell exists only where a row has that column index.
### Notes / Edge cases
- A neighbor cell is valid only if it is within the bounds of its row.
- A house may consist of a single cell.
- Assume the number of rows can exceed 26; specify how you will label rows beyond `Z` (e.g., `AA`, `AB`, ...) or state that inputs are limited to 26 rows.
### Constraints (you may assume)
- Total number of cells across all rows is up to a reasonable limit (e.g., `<= 2e5`).
Design an algorithm to find all houses and their bounding boxes.
Quick Answer: This question evaluates grid traversal and connected-component identification skills, specifically handling ragged 2D arrays, 4-directional adjacency, axis-aligned bounding-box computation, and index-to-label coordinate encoding.