Ezvor

2247. Maximum Cost of Trip With K Highways

HardDynamic Programming Preparing judge… LeetCode
Dynamic ProgrammingBit ManipulationGraph TheoryBitmask

Hints

Hint 1
Are there any computations being repeated?
Hint 2
The same path can be visited multiple times. Could we reuse the previously calculated result?
Hint 3
Store the nodes seen on the current path and the last node on the current path as a dynamic programming state.