Skip to content

Commit 6c82d5e

Browse files
authored
Create Minimum Cost to Reach Every Position.java
1 parent e6687a6 commit 6c82d5e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int[] minCosts(int[] cost) {
3+
int n = cost.length;
4+
int[] result = new int[n];
5+
int minCost = Integer.MAX_VALUE;
6+
for (int i = 0; i < n; i++) {
7+
int curr = cost[i];
8+
minCost = Math.min(minCost, curr);
9+
result[i] = minCost;
10+
}
11+
return result;
12+
}
13+
}

0 commit comments

Comments
 (0)