NeetCode #645LC-3108HardAdvanced Graphs
← Back to All Problems#645 · #3108 · Minimum Cost Walk in Weighted Graph(带权图里旅游的最小代价)
📌 Problem Statement & Constraints
You are given
n nodes, edges[i] = [u, v, w] as undirected weighted edges, and query[i] = [s, t]. The cost of a walk from s to t is the bitwise AND of all edge weights on it. Return the minimum cost for each query, or -1 if unreachable. Constraints: 2 <= n <= 10^5, 1 <= edges.length <= 10^5, 1 <= query.length <= 10^5.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!