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

Commit 9a14a15

Browse files
feat: add typescript solution to lc problem: No.2319
No.2319.Check if Matrix Is X-Matrix
1 parent 33cf9f8 commit 9a14a15

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

‎solution/2300-2399/2319.Check if Matrix Is X-Matrix/README.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,19 @@ func checkXMatrix(grid [][]int) bool {
139139
### **TypeScript**
140140

141141
```ts
142-
142+
function checkXMatrix(grid: number[][]): boolean {
143+
const m = grid.length, n = grid[0].length;
144+
for (let i = 0; i < m; i++) {
145+
for (let j = 0; j < n; j++) {
146+
if (j == i || j == (n - 1 - i)) {
147+
if (!grid[i][j]) return false;
148+
} else {
149+
if (grid[i][j]) return false;
150+
}
151+
}
152+
}
153+
return true;
154+
};
143155
```
144156

145157
### **...**

‎solution/2300-2399/2319.Check if Matrix Is X-Matrix/README_EN.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,19 @@ func checkXMatrix(grid [][]int) bool {
131131
### **TypeScript**
132132

133133
```ts
134-
134+
function checkXMatrix(grid: number[][]): boolean {
135+
const m = grid.length, n = grid[0].length;
136+
for (let i = 0; i < m; i++) {
137+
for (let j = 0; j < n; j++) {
138+
if (j == i || j == (n - 1 - i)) {
139+
if (!grid[i][j]) return false;
140+
} else {
141+
if (grid[i][j]) return false;
142+
}
143+
}
144+
}
145+
return true;
146+
};
135147
```
136148

137149
### **...**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function checkXMatrix(grid: number[][]): boolean {
2+
const m = grid.length, n = grid[0].length;
3+
for (let i = 0; i < m; i++) {
4+
for (let j = 0; j < n; j++) {
5+
if (j == i || j == (n - 1 - i)) {
6+
if (!grid[i][j]) return false;
7+
} else {
8+
if (grid[i][j]) return false;
9+
}
10+
}
11+
}
12+
return true;
13+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /