#3108

Minimum Cost Walk in Weighted Graph

expert · 1025 · lc hard +32 · 68.3% accepted · 783 likes · top 75%

Description

An undirected weighted graph has n vertices (0 to n - 1) with edges edges[i] = [ui, vi, wi]. A walk may revisit vertices and edges. The cost of a walk is the bitwise AND of all edge weights along it. For each query [si, ti], return the minimum cost walk from si to ti, or -1 if they are disconnected.

Code

1
2
3