Count Occupied Voxels in a Lidar Point Cloud

Last updated: November 29, 2026

Quick Overview

Given a list of 3D lidar points and a voxel edge length, return how many distinct voxels contain at least one point and which voxel holds the most points (ties broken by the smallest voxel index).

Applied Intuition
Coding & Algorithms
Software Engineer
Applied Intuition
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of 3D lidar points and a voxel edge length, return how many distinct voxels contain at least one point and which voxel holds the most points (ties broken by the smallest voxel index).

A warm-up in the style of Applied Intuition's phone screens, where sensor simulation and perception tooling work with point clouds constantly. The interviewer checks clean hashing, correct handling of negative coordinates, and whether you think about tie-breaking before being asked.

What the Interviewer Expects
  • Map each point to an integer voxel key with floor division, not int truncation
  • Use a hash map from voxel key to count in one pass
  • Define and implement a deterministic tie-break
  • Handle an empty cloud and a non-positive voxel size
  • State linear time and memory proportional to occupied voxels
Key Topics to Cover
hash maps
floor division
point clouds
voxel grids
tie-breaking
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
  • How would you return the centroid of each voxel for downsampling?
  • What changes if the cloud has 200 million points and does not fit in memory?
  • How would you find all voxels with at least M points efficiently?
  • How would you make voxel keys cheaper than tuples in a hot loop?
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 is a list of (x, y, z) floats in meters and a positive voxel size. Output is (occupied_count, densest_voxel, densest_count). I will confirm voxels are axis-aligned with the origin at a corne...

High-Level Design

Each point maps to (floor(x/s), floor(y/s), floor(z/s)). Counting by key in a dictionary gives occupancy directly; the densest voxel is the key with the largest count. For ties I sort by `(-count, k...


Submit Your Answer
Markdown supported

Related Questions