#3543

Maximum Weighted K-Edge Path

expert · 1195 · lc medium +32 · 19.9% accepted · 86 likes · top 1%

Description

In a DAG with n nodes and weighted edges edges[i] = [ui, vi, wi], find the maximum total weight of a path using exactly k edges, provided that total weight is strictly less than t.

Return that maximum weight, or -1 if no qualifying path exists.

Code

1
2
3