#3532
Path Existence Queries in a Graph I
specialist · 795 · lc medium +31 · 55.3% accepted · 109 likes · top 48%
Description
Build a graph on n nodes (0 to n-1) using sorted array nums: connect nodes i and j when |nums[i] - nums[j]| <= maxDiff.
For each query [ui, vi], answer whether nodes ui and vi are connected.
Return a boolean array of results.
Code
1
2
3