Skip to content

Commit 17dfec8

Browse files
add 2965
1 parent 02237ad commit 17dfec8

File tree

2 files changed

+27
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src/main/java/com/fishercoder/solutions/thirdthousand

2 files changed

+27
-0
lines changed

paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|---------------------------|----------------------------------------------------------------------
3+
| 2965 | [Find Missing and Repeated Values](https://leetcode.com/problems/find-missing-and-repeated-values/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2965.java) | | Easy |
34
| 2864 | [Maximum Odd Binary Number](https://leetcode.com/problems/maximum-odd-binary-number/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2864.java) | | Easy |Greedy
45
| 2812 | [Find the Safest Path in a Grid](https://leetcode.com/problems/find-the-safest-path-in-a-grid/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2812.java) | | Medium |BFS
56
| 2751 | [Robot Collisions](https://leetcode.com/problems/robot-collisions/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2751.java) | | Hard | Stack, Simulation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _2965 {
7+
public static class Solution1 {
8+
public int[] findMissingAndRepeatedValues(int[][] grid) {
9+
Set<Integer> set = new HashSet<>();
10+
int[] result = new int[2];
11+
for (int i = 0; i < grid.length; i++) {
12+
for (int j = 0; j < grid[0].length; j++) {
13+
if (!set.add(grid[i][j])) {
14+
result[0] = grid[i][j];
15+
}
16+
}
17+
}
18+
for (int i = 1; i <= grid.length * grid.length; i++) {
19+
if (!set.contains(i)) {
20+
result[1] = i;
21+
}
22+
}
23+
return result;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)