PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Google

Can you reach target with distance-threshold edges?

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of graph connectivity and spatial proximity modeling, examining competencies in graph algorithms and computational geometry within the Coding & Algorithms domain relevant for Machine Learning Engineer roles.

  • hard
  • Google
  • Coding & Algorithms
  • Machine Learning Engineer

Can you reach target with distance-threshold edges?

Company: Google

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a set of unordered 2D points `points[]`, a `start` point and an `end` point (both are included in `points`), and a function: ```text getDistance(p, q) ``` that returns the distance between two points `p` and `q`. Define an undirected graph where two points are connected by an edge **iff** `getDistance(p, q) < r` for a given threshold `r`. Task: Determine whether there exists a path from `start` to `end`. Follow-up: If `points` is very large and calling `getDistance` is expensive, how would you reduce repeated distance computations and/or avoid checking all pairs?

Quick Answer: This question evaluates understanding of graph connectivity and spatial proximity modeling, examining competencies in graph algorithms and computational geometry within the Coding & Algorithms domain relevant for Machine Learning Engineer roles.

Related Interview Questions

  • Compute Turnstile Crossing Times - Google (hard)
  • Simulate In-Place Cellular State Updates - Google (hard)
  • Determine Whether a Word Exists in a Graph - Google (medium)
  • Solve Shortest Paths and Rental Allocation - Google (medium)
  • Solve Two Array Optimization Problems - Google (medium)
Google logo
Google
Feb 22, 2026, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
8
0

You are given a set of unordered 2D points points[], a start point and an end point (both are included in points), and a function:

getDistance(p, q)

that returns the distance between two points p and q.

Define an undirected graph where two points are connected by an edge iff getDistance(p, q) < r for a given threshold r.

Task: Determine whether there exists a path from start to end.

Follow-up: If points is very large and calling getDistance is expensive, how would you reduce repeated distance computations and/or avoid checking all pairs?

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Machine Learning Engineer•Google Machine Learning Engineer•Google Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.