Graph Theory37 sections · 1633 units
Open in Course

LeetCode 1697 Edge Limited Paths - Problem Statement

LeetCode 1697

Problem: Checking Existence of Edge Length Limited Paths Task: Given edges with weights and queries (u,v,limit)(u, v, limit), determine if uu and vv are connected using only edges with weight <limit< limit.

Sort edges and queries by weight. Process them together. Answer queries when their limit is reached. As you process queries in increasing order of limit, add all edges with weight below the current limit. Then check connectivity with DSU. This offline approach avoids rebuilding the graph for each query.