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

Commitbc5f38e

Browse files
add 2319
1 parent4aa6fb7 commitbc5f38e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-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+
| 2319|[Check if Matrix Is X-Matrix](https://leetcode.com/problems/check-if-matrix-is-x-matrix/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2319.java)|| Easy||
1112
| 2315|[Count Asterisks](https://leetcode.com/problems/count-asterisks/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2315.java)|| Easy||
1213
| 2309|[Greatest English Letter in Upper and Lower Case](https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2309.java)|| Easy||
1314
| 2303|[Calculate Amount Paid in Taxes](https://leetcode.com/problems/calculate-amount-paid-in-taxes/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2303.java)|| Easy||
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_2319 {
4+
publicstaticclassSolution1 {
5+
publicbooleancheckXMatrix(int[][]grid) {
6+
intm =grid.length;
7+
boolean[][]checked =newboolean[m][m];
8+
for (inti =0;i <m;i++) {
9+
if (grid[i][i] ==0) {
10+
returnfalse;
11+
}else {
12+
checked[i][i] =true;
13+
}
14+
}
15+
for (inti =0,j =m -1;i <m &&j >=0;i++,j--) {
16+
if (grid[i][j] ==0) {
17+
returnfalse;
18+
}else {
19+
checked[i][j] =true;
20+
}
21+
}
22+
for (inti =0;i <m;i++) {
23+
for (intj =0;j <m;j++) {
24+
if (!checked[i][j] &&grid[i][j] !=0) {
25+
returnfalse;
26+
}
27+
}
28+
}
29+
returntrue;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp