Problem: Checking Existence of Edge Length Limited Paths Task: Given edges with weights and queries , determine if and are connected using only edges with weight .
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.