File tree 3 files changed +53
-0
lines changed
3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 211
211
| 2299| [ 强密码检验器 II] ( https://leetcode.cn/problems/strong-password-checker-ii/ ) | [ JavaScript] ( ./algorithms/strong-password-checker-ii.js ) | Easy|
212
212
| 2309| [ 兼具大小写的最好英文字母] ( https://leetcode.cn/problems/greatest-english-letter-in-upper-and-lower-case/ ) | [ JavaScript] ( ./algorithms/greatest-english-letter-in-upper-and-lower-case.js ) | Easy|
213
213
| 2315| [ 统计星号] ( https://leetcode.cn/problems/count-asterisks/ ) | [ JavaScript] ( ./algorithms/count-asterisks.js ) | Easy|
214
+ | 2319| [ 判断矩阵是否是一个 X 矩阵] ( https://leetcode.cn/problems/check-if-matrix-is-x-matrix/ ) | [ JavaScript] ( ./algorithms/check-if-matrix-is-x-matrix.js ) | Easy|
214
215
| 2351| [ 第一个出现两次的字母] ( https://leetcode.cn/problems/first-letter-to-appear-twice/ ) | [ JavaScript] ( ./algorithms/first-letter-to-appear-twice.js ) | Easy|
215
216
| 面试题 04.12| [ 面试题 04.12. 求和路径] ( https://leetcode.cn/problems/paths-with-sum-lcci/ ) | [ JavaScript] ( ./algorithms/paths-with-sum-lcci.js ) | Medium|
216
217
| 面试题 02.07| [ 面试题 02.07. 链表相交] ( https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/ ) | [ JavaScript] ( ./algorithms/intersection-of-two-linked-lists-lcci.js ) | Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * [2319] 判断矩阵是否是一个 X 矩阵
3
+ * @param {number[][] } grid
4
+ * @return {boolean }
5
+ */
6
+ var checkXMatrix = function ( grid ) {
7
+ const row = grid . length ;
8
+ const col = grid [ 0 ] . length ;
9
+
10
+ for ( let i = 0 ; i < row ; i ++ ) {
11
+ for ( let j = 0 ; j < col ; j ++ ) {
12
+ if ( i === j || i + j === col - 1 ) { // 45°对角线 135°对角线
13
+ if ( grid [ i ] [ j ] === 0 ) {
14
+ return false ;
15
+ }
16
+ } else if ( grid [ i ] [ j ] !== 0 ) {
17
+ return false ;
18
+ }
19
+ }
20
+ }
21
+ return true ;
22
+ } ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * @lc app=leetcode.cn id=2319 lang=javascript
3
+ *
4
+ * [2319] 判断矩阵是否是一个 X 矩阵
5
+ */
6
+
7
+ // @lc code=start
8
+ /**
9
+ * @param {number[][] } grid
10
+ * @return {boolean }
11
+ */
12
+ var checkXMatrix = function ( grid ) {
13
+ const row = grid . length ;
14
+ const col = grid [ 0 ] . length ;
15
+
16
+ for ( let i = 0 ; i < row ; i ++ ) {
17
+ for ( let j = 0 ; j < col ; j ++ ) {
18
+ if ( i === j || i + j === col - 1 ) { // 45°对角线 135°对角线
19
+ if ( grid [ i ] [ j ] === 0 ) {
20
+ return false ;
21
+ }
22
+ } else if ( grid [ i ] [ j ] !== 0 ) {
23
+ return false ;
24
+ }
25
+ }
26
+ }
27
+ return true ;
28
+ } ;
29
+ // @lc code=end
30
+
You can’t perform that action at this time.
0 commit comments