2737. Find the Closest Marked Node
You are given a positive integer
n
which is the number of nodes of a 0-indexed directed weighted graph and a 0-indexed 2D arrayedges
whereedges[i] = [ui, vi, wi]
indicates that there is an edge from nodeui
to nodevi
with weightwi
.You are also given a node
s
and a node arraymarked
; your task is to find the minimum distance froms
to any of the nodes inmarked
.Return an integer denoting the minimum distance from
s
to any node inmarked
or-1
if there are no paths from s to any of the marked nodes.
c++
1 | class Solution { |