Cluster Occupied Cells in a Lidar Occupancy Grid
Last updated: November 29, 2026
Quick Overview
Given a 2D occupancy grid built from lidar returns (1 = occupied, 0 = free), group occupied cells into 8-connected obstacle clusters and return each cluster's bounding box and cell count, dropping clusters smaller than min_cells.
Aurora
November 29, 20260
0
0 solved
Given a 2D occupancy grid built from lidar returns (1 = occupied, 0 = free), group occupied cells into 8-connected obstacle clusters and return each cluster's bounding box and cell count, dropping clusters smaller than min_cells.
Before tracking, an autonomy stack often needs to turn raw returns into discrete objects, and a bird's-eye occupancy grid is a classic representation for that. The interviewer checks graph traversal on a grid, connectivity choice, and noise filtering that matters when a truck sees debris, spray, or sparse returns at range.
What the Interviewer Expects
- Uses BFS or iterative DFS with a visited set (no recursion depth blowup on big grids)
- Explains 8-connectivity versus 4-connectivity and why it matters for diagonal objects
- Tracks bounding box and size during the traversal
- Filters small clusters as likely noise
- Gives O(rows*cols) complexity
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you cluster directly on 3D points instead of a grid?
- The grid is 2000 by 2000 at 10 cm cells: how would you make this fast enough for 10 Hz?
- How do you avoid merging a parked car and a guardrail that touch in the grid?
- How would you keep cluster IDs stable across frames?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: grid as a list of lists of 0/1 and min_cells. Output: list of (r_min, c_min, r_max, c_max, size) per cluster in scan order. Neighbors are the 8 surrounding cells, because a vehicle seen a...
High-Level Design
Scan every cell. When I find an unvisited occupied cell, start a BFS, mark cells visited when they are enqueued (not dequeued, to avoid duplicates), and update the bounding box and count as I pop them...