Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Reach Every Position

med
30 min
Try to solve the Minimum Cost to Reach Every Position problem.

Statement

You are given an integer array cost of length n.

You want to reach every target position i from 00 to n −1- 1. To reach position i, you may choose any index j such that 0≤j≤i0 \leq j \leq i and pay cost[j].

Return an integer array ans of length n, where ans[i] is the minimum cost required to reach position i.

Constraints:

  • 1≤1 \leq n ==== cost.length ≤100\leq 100

  • 1≤1 \leq cost[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Reach Every Position

med
30 min
Try to solve the Minimum Cost to Reach Every Position problem.

Statement

You are given an integer array cost of length n.

You want to reach every target position i from 00 to n −1- 1. To reach position i, you may choose any index j such that 0≤j≤i0 \leq j \leq i and pay cost[j].

Return an integer array ans of length n, where ans[i] is the minimum cost required to reach position i.

Constraints:

  • 1≤1 \leq n ==== cost.length ≤100\leq 100

  • 1≤1 \leq cost[i] ≤100\leq 100