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 Original file line number Diff line number Diff line change 1
1
| # | Title | Solutions | Video | Difficulty | Tag
2
2
|------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|---------------------------|----------------------------------------------------------------------
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 |
3
4
| 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
4
5
| 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
5
6
| 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 number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments