Longest Shared Geohash Prefix Across a Batch of Pickups

Last updated: November 29, 2026

Quick Overview

Given a list of pickup geohash strings, return the longest prefix shared by all of them, which identifies the smallest geohash cell containing every pickup.

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

0

0

0 solved


Given a list of pickup geohash strings, return the longest prefix shared by all of them, which identifies the smallest geohash cell containing every pickup.

A quick Uber phone screen question tied to geospatial bucketing, since geohash prefixes map to nested map cells. It checks string handling and whether you know a trie or sort-based shortcut.

What the Interviewer Expects
  • Explains why a shared geohash prefix means a shared enclosing cell
  • Builds a trie and walks while each node has one child and no word ends
  • Mentions the min and max string trick as an alternative
  • Handles an empty list and an empty string
  • States O(total characters) time
Key Topics to Cover
trie
strings
prefix
geohash
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
  • Group pickups into the fewest cells of a fixed precision.
  • How would you find the longest prefix shared by at least 80 percent of pickups?
  • Why can two nearby points have very different geohashes, and how do you handle it?
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 geohash strings (base32 characters).
  • Output: longest common prefix, possibly empty.
  • Empty input returns an empty string....
High-Level Design

Insert all geohashes into a trie, marking where any string ends. The common prefix is the path from the root while the current node has exactly one child and no string ends there. A shortcut avoids th...


Submit Your Answer
Markdown supported