Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For each index, find the indexes that you can jump to.
We can do this by using a monotonic stack and iterating through the array backwards.
Create another integer array of length n called dp where dp[i] is the minimum cost of getting to index i.