This is a more advanced version of the previous problem. In this "Hard" variation, you must answer queries "Online," meaning you cannot sort them beforehand. You need a data structure that can efficiently answer if a path between exists using only edges with weight less than , even as queries come in one by one.
Google and Oscar Health use this to test your knowledge of advanced tree structures like the Kruskal Reconstruction Tree or Persistent Union Find. It evaluates your ability to handle dynamic graph connectivity and your understanding of Minimum Spanning Trees (MST). This is a very high-level problem that tests the limits of a candidate's algorithmic toolkit.
This problem is best solved using a Kruskal Reconstruction Tree. When building an MST using Kruskal's algorithm, instead of just connecting two nodes, you create a new "parent" node whose weight is the weight of the edge connecting them. The result is a tree where the "bottleneck" (maximum edge weight) on the path between any two original nodes is the value of their Lowest Common Ancestor (LCA). Queries then become a simple LCA check.
Edges: (A-B, 3), (B-C, 5).
The main challenge is knowing the specific data structure needed. Without a Kruskal Reconstruction Tree or similar persistent structure, an "Online" version of this problem is nearly impossible to solve within time limits. Candidates might also struggle with implementing the Binary Lifting technique needed to find the LCA efficiently.
Study the relationship between MSTs and the "Minimax Path" (the path that minimizes the maximum edge weight). This concept is the foundation for many advanced network and graph optimization problems.