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

Commit bc5f38e

Browse files
add 2319
1 parent 4aa6fb7 commit bc5f38e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

+1
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 ||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _2319 {
4+
public static class Solution1 {
5+
public boolean checkXMatrix(int[][] grid) {
6+
int m = grid.length;
7+
boolean[][] checked = new boolean[m][m];
8+
for (int i = 0; i < m; i++) {
9+
if (grid[i][i] == 0) {
10+
return false;
11+
} else {
12+
checked[i][i] = true;
13+
}
14+
}
15+
for (int i = 0, j = m - 1; i < m && j >= 0; i++, j--) {
16+
if (grid[i][j] == 0) {
17+
return false;
18+
} else {
19+
checked[i][j] = true;
20+
}
21+
}
22+
for (int i = 0; i < m; i++) {
23+
for (int j = 0; j < m; j++) {
24+
if (!checked[i][j] && grid[i][j] != 0) {
25+
return false;
26+
}
27+
}
28+
}
29+
return true;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)