PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Nuro

Group points by distance threshold

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of geometric graph construction and connectivity, computational geometry concepts such as Euclidean distance, and algorithmic scalability for grouping points.

  • medium
  • Nuro
  • Coding & Algorithms
  • Software Engineer

Group points by distance threshold

Company: Nuro

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given **N points** in 2D space, `points[i] = (xi, yi)`, and a distance threshold `k > 0`. Define an undirected graph where there is an edge between two points `i` and `j` if their **Euclidean distance** is **strictly less than `k`**. A **group** is a connected component of this graph (i.e., grouping is **transitive**: if A is within `k` of B and B is within `k` of C, then A, B, C are in the same group even if A and C are not directly within `k`). ### Task Return the grouping of points (e.g., the number of groups and/or the list of point indices in each group). ### Follow-up If `N` is very large and points are very **sparse** (most pairs are far apart), how would you **reduce the number of distance computations** compared to checking all `O(N^2)` pairs? ### Assumptions / constraints (you may state your own) - `1 <= N <= 2e5` - Coordinates are integers in a large range (e.g., `[-1e9, 1e9]`). - Distance is Euclidean: `dist((x1,y1),(x2,y2)) = sqrt((x1-x2)^2 + (y1-y2)^2)`.

Quick Answer: This question evaluates understanding of geometric graph construction and connectivity, computational geometry concepts such as Euclidean distance, and algorithmic scalability for grouping points.

Related Interview Questions

  • Parse logs and count error codes - Nuro (easy)
  • Find Maximum Path Sum in N-ary Tree - Nuro (hard)
  • Find gaps between intervals - Nuro (medium)
  • Implement BFS and a Job Scheduler - Nuro (hard)
Nuro logo
Nuro
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0
Loading...

You are given N points in 2D space, points[i] = (xi, yi), and a distance threshold k > 0.

Define an undirected graph where there is an edge between two points i and j if their Euclidean distance is strictly less than k. A group is a connected component of this graph (i.e., grouping is transitive: if A is within k of B and B is within k of C, then A, B, C are in the same group even if A and C are not directly within k).

Task

Return the grouping of points (e.g., the number of groups and/or the list of point indices in each group).

Follow-up

If N is very large and points are very sparse (most pairs are far apart), how would you reduce the number of distance computations compared to checking all O(N^2) pairs?

Assumptions / constraints (you may state your own)

  • 1 <= N <= 2e5
  • Coordinates are integers in a large range (e.g., [-1e9, 1e9] ).
  • Distance is Euclidean: dist((x1,y1),(x2,y2)) = sqrt((x1-x2)^2 + (y1-y2)^2) .

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Nuro•More Software Engineer•Nuro Software Engineer•Nuro Coding & Algorithms•Software 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.