Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6adfdf0

Browse filesBrowse files
[LEET-3502] add 3502
1 parent efa91d4 commit 6adfdf0
Copy full SHA for 6adfdf0

File tree

3 files changed

+40
-0
lines changed
Filter options
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+40
-0
lines changed

‎paginated_contents/algorithms/4th_thousand/README.md

Copy file name to clipboardExpand all lines: paginated_contents/algorithms/4th_thousand/README.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
3+
| 3502 | [Minimum Cost to Reach Every Position](https://leetcode.com/problems/minimum-cost-to-reach-every-position/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3502.java) | | Easy |
34
| 3471 | [Find the Largest Almost Missing Integer](https://leetcode.com/problems/find-the-largest-almost-missing-integer/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3471.java) | | Easy |
45
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3396.java) | | Easy |
56
| 3392 | [Count Subarrays of Length Three With a Condition](https://leetcode.com/problems/count-subarrays-of-length-three-with-a-condition/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3392.java) | | Easy |
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3502 {
4+
public static class Solution1 {
5+
public int[] minCosts(int[] cost) {
6+
int[] res = new int[cost.length];
7+
int min = cost[0];
8+
for (int i = 0; i < cost.length; i++) {
9+
if (cost[i] < min) {
10+
min = cost[i];
11+
}
12+
res[i] = min;
13+
}
14+
return res;
15+
}
16+
}
17+
}
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.fourththousand;
2+
3+
import com.fishercoder.solutions.fourththousand._3502;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
8+
9+
public class _3502Test {
10+
private _3502.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _3502.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertArrayEquals(new int[]{5, 3, 3, 1, 1, 1}, solution1.minCosts(new int[]{5, 3, 4, 1, 3, 2}));
20+
}
21+
22+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.