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

Commitdab0bcc

Browse files
authored
Create Check if Matrix Is X-Matrix.java
1 parentfd70090 commitdab0bcc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎Easy/Check if Matrix Is X-Matrix.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
classSolution {
2+
publicbooleancheckXMatrix(int[][]grid) {
3+
intn =grid.length;
4+
for (inti =0;i <n;i++) {
5+
for (intj =0;j <n;j++) {
6+
if (i ==j ||i +j ==n -1) {
7+
if (grid[i][j] ==0) {
8+
returnfalse;
9+
}
10+
}else {
11+
if (grid[i][j] !=0) {
12+
returnfalse;
13+
}
14+
}
15+
}
16+
}
17+
returntrue;
18+
}
19+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp