We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4fc8190 commit 3ff1b8fCopy full SHA for 3ff1b8f
README.md
@@ -10,6 +10,8 @@ leetcode 测试
10
11
##### 包含的内容如下
12
13
+https://leetcode.cn/problems/matrix-diagonal-sum/
14
+
15
https://leetcode.cn/problems/thousand-separator/
16
17
https://leetcode.cn/problems/count-odd-numbers-in-an-interval-range/
matrix-diagonal-sum/index.ts
@@ -0,0 +1,9 @@
1
+export default function diagonalSum(e: number[][]) {
2
+ return e.reduce(
3
+ (e, _n, r, t) =>
4
+ r === t.length - r - 1
5
+ ? e + t[r][r]
6
+ : e + t[r][r] + t[r][t.length - r - 1],
7
+ 0
8
+ );
9
+}
0 commit comments