Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit92e72bd

Browse files
add 2133
1 parent4806a7d commit92e72bd

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+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.HashSet;
4+
importjava.util.Set;
5+
6+
publicclass_2133 {
7+
publicstaticclassSolution1 {
8+
publicbooleancheckValid(int[][]matrix) {
9+
intn =matrix.length;
10+
Set<Integer>set =newHashSet<>();
11+
for (inti =1;i <=n;i++) {
12+
set.add(i);
13+
}
14+
for (inti =0;i <n;i++) {
15+
Set<Integer>copy =newHashSet<>(set);
16+
for (intj =0;j <n;j++) {
17+
if (!copy.remove(matrix[i][j])) {
18+
returnfalse;
19+
}
20+
}
21+
}
22+
for (intj =0;j <n;j++) {
23+
Set<Integer>copy =newHashSet<>(set);
24+
for (inti =0;i <n;i++) {
25+
if (!copy.remove(matrix[i][j])) {
26+
returnfalse;
27+
}
28+
}
29+
}
30+
returntrue;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp