Network Recovery Pathways

Solution
class Solution:
    def findMaxPathScore(self, edges: List[List[int]], online: List[bool], k: int) -> int:
        n = len(online)
        g = [[] for _ in range(n)]
        l, r = float("inf"), 0
        
        for u, v, w in edges:
            if not online[u] or not online[v]:
                continue
            g[u].append((v, w))
            l = min(l, w)
            r = max(r, w)
            
        def check(mid: int) -> bool:
            # Dijkstra implementation here...
            pass
            
        res = -1
        while l <= r:
            mid = (l + r) // 2
            if check(mid):
                res = mid
                l = mid + 1
            else:
                r = mid - 1
        return res

Time Complexity

O((V + E) log U)

Space Complexity

O(V + E)