Bucket Pickup Pins Into Grid Cells and Find Hotspots
Last updated: November 29, 2026
Quick Overview
Given pickup coordinates in meters on a flat city plane and a cell size s, bucket each pin into a square grid cell and return the cells that contain at least t pins, sorted by count descending.
Uber
November 29, 20260
0
0 solved
Given pickup coordinates in meters on a flat city plane and a cell size s, bucket each pin into a square grid cell and return the cells that contain at least t pins, sorted by count descending.
This mirrors how Uber aggregates demand into spatial cells (the production system uses H3 hexagons) before surge or driver repositioning logic runs. In an online assessment the grader checks that you key a hash map by a computed cell id, handle negative coordinates correctly, and produce deterministic output ordering.
What the Interviewer Expects
- Compute a cell key with floor division, not int truncation
- Aggregate with a hash map or Counter
- Filter by threshold and sort with a deterministic tie-break
- Recognize negative coordinate pitfalls
- Discuss why real systems use hexagonal cells
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 neighboring cells be included so a hotspot on a cell boundary is not split?
- Why might hexagons beat squares for demand aggregation?
- How would you compute this over a sliding 5 minute window of pins?
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: list of
(x, y)floats in meters, cell sizes > 0, thresholdt. - Cell of a point is
(floor(x / s), floor(y / s)). - Output: list of
(cell, count)withcount >= t, sorted by count ...
High-Level Design
Each pin maps to exactly one cell, so this is a group-by on a derived key. The only subtle part is the key itself: int(-0.5 / 100) is 0 in Python, but the point belongs to cell -1. Using `math.f...