Available question text
Given n and array nums, build an undirected unweighted graph where an edge exists between i and j iff |nums[i] - nums[j]| ≤ maxDiff, and answer many queries asking the shortest path length (or -1 if unreachable) between specified node pairs. The core challenge is to compute distances efficiently for up to 1e5 nodes/queries without explicitly building the potentially dense O(n^2) graph by exploiting the value-proximity structure.
Related questions
Continue with questions that share topics or the same question type.
- Path Existence Queries in a Graph I
Coding
- Design Graph With Shortest Path Calculator
Coding
- Find if Path Exists in Graph
Coding
- Implement Social Graph Snapshot Queries
Coding · Data Structure Design · Graphs
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3534. Path Existence Queries in a Graph II
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source