Search
⌘K

Leetcode 3502. Minimum Cost to Reach Every Position

Starting from position n you can reach any target i by paying some person j ≤ i to swap once (cost[j]) and then moving through the rest for free, so the minimum cost to reach i is simply the minimum of cost[0..i]; compute these prefix minima for all i.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.