Search
⌘K

Leetcode 3108. Minimum Cost Walk in Weighted Graph

For each query, find the smallest possible bitwise AND of edge weights along any walk (edges/vertices may repeat) between two nodes in an undirected weighted graph, or return -1 if they are disconnected. The core challenge is exploiting the monotonic properties of bitwise AND together with fast connectivity checks to determine which bitmask values are achievable at scale (n, edges, queries up to 1e5).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.