Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Are there any computations being repeated?
The same path can be visited multiple times. Could we reuse the previously calculated result?
Store the nodes seen on the current path and the last node on the current path as a dynamic programming state.