Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 92e72bd

Browse files
add 2133
1 parent 4806a7d commit 92e72bd

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2133|[Check if Every Row and Column Contains All Numbers](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2133.java) ||Easy||
1112
|2130|[Maximum Twin Sum of a Linked List](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2130.java) ||Medium||
1213
|2129|[Capitalize the Title](https://leetcode.com/problems/capitalize-the-title/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2129.java) ||Easy||
1314
|2126|[Destroying Asteroids](https://leetcode.com/problems/destroying-asteroids/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2126.java) ||Medium||
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _2133 {
7+
public static class Solution1 {
8+
public boolean checkValid(int[][] matrix) {
9+
int n = matrix.length;
10+
Set<Integer> set = new HashSet<>();
11+
for (int i = 1; i <= n; i++) {
12+
set.add(i);
13+
}
14+
for (int i = 0; i < n; i++) {
15+
Set<Integer> copy = new HashSet<>(set);
16+
for (int j = 0; j < n; j++) {
17+
if (!copy.remove(matrix[i][j])) {
18+
return false;
19+
}
20+
}
21+
}
22+
for (int j = 0; j < n; j++) {
23+
Set<Integer> copy = new HashSet<>(set);
24+
for (int i = 0; i < n; i++) {
25+
if (!copy.remove(matrix[i][j])) {
26+
return false;
27+
}
28+
}
29+
}
30+
return true;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)