最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

LeetCode 1572. Matrix Diagonal Sum

2023-02-01 16:19 作者:您是打尖兒還是住店呢  | 我要投稿

Given a?square?matrix?mat, return the sum of the matrix diagonals.

Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.

?

Example 1:

Input: mat = [[1,2,3], [4,5,6],[7,8,9]]

Output: 25

Explanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25?

Notice that element mat[1][1] = 5 is counted only once.

Example 2:

Input: mat = [[1,1,1,1],?[1,1,1,1],?[1,1,1,1], [1,1,1,1]]

Output: 8

Example 3:

Input: mat = [[5]]

Output: 5

?

Constraints:

  • n == mat.length == mat[i].length

  • 1 <= n <= 100

  • 1 <= mat[i][j] <= 100


Easy題目就不細(xì)說了。

Runtime:?0 ms, faster than?100.00%?of?Java?online submissions for?Matrix Diagonal Sum.

Memory Usage:?42.3 MB, less than?70.06%?of?Java?online submissions for?Matrix Diagonal Sum.


LeetCode 1572. Matrix Diagonal Sum的評論 (共 條)

分享到微博請遵守國家法律
屏边| 双桥区| 清涧县| 兴安县| 临清市| 蒙阴县| 和龙市| 长子县| 云林县| 湖州市| 凯里市| 秀山| 象山县| 鄂尔多斯市| 绵竹市| 南乐县| 黑龙江省| 金平| 罗甸县| 抚远县| 当涂县| 湘西| 瑞丽市| 石台县| 噶尔县| 巴林左旗| 南安市| 朝阳县| 习水县| 秦皇岛市| 郎溪县| 三门县| 普格县| 建瓯市| 青州市| 云梦县| 凤庆县| 阳原县| 巴青县| 洛浦县| 元江|