PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in Python code review and geolocation data-processing, including competencies in readability, correctness, performance optimization, and architectural scalability.

  • Medium
  • Airbnb
  • Coding & Algorithms
  • Software Engineer

Review Python geodata code

Company: Airbnb

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

##### Question You are given a Python codebase that performs geolocation data processing. Conduct a thorough code review: identify readability, correctness, performance, and scalability issues, and propose concrete refactors or optimizations (e.g., data structures, vectorization, caching, modularization).

Quick Answer: This question evaluates proficiency in Python code review and geolocation data-processing, including competencies in readability, correctness, performance optimization, and architectural scalability.

Given a list of GPS points as (latitude, longitude) and an integer precision p, partition the plane into a uniform grid where each cell spans 10^-p degrees in both latitude and longitude. Map each point to its grid cell using integer tile indices i = floor(lat * 10^p + 1e-12) and j = floor(lon * 10^p + 1e-12). Return the number of distinct grid cells visited by the points. If the list is empty, return 0.

Constraints

  • 0 <= n <= 200000
  • -90.0 <= latitude <= 90.0
  • -180.0 <= longitude <= 180.0
  • 0 <= precision <= 6
  • Quantization uses i = floor(lat * 10^precision + 1e-12), j = floor(lon * 10^precision + 1e-12)
  • Return the count of unique (i, j) pairs

Hints

  1. Convert each point to integer tile indices and use a set to track uniqueness.
  2. Precompute scale = 10**precision and avoid Python's round; use math.floor with a tiny epsilon to counter floating-point noise.
  3. If many identical points appear, caching their tile result can reduce repeated computation.
Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Count Candies from Unlockable Boxes - Airbnb (medium)
  • Find Optimal Property Combination - Airbnb (medium)
  • Determine Exact Layover Booking - Airbnb (medium)
  • Solve Linked-List and Iterator Problems - Airbnb
  • Implement Text Layout and Query Parsing - Airbnb (easy)