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
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

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
hash map
spatial bucketing
floor division
sorting with tie-breaks
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 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 Problems
Sample Answer
Requirements
  • Input: list of (x, y) floats in meters, cell size s > 0, threshold t.
  • Cell of a point is (floor(x / s), floor(y / s)).
  • Output: list of (cell, count) with count >= 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...


Submit Your Answer
Markdown supported

Related Questions