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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
浪卡子县| 封丘县| 临桂县| 江津市| 侯马市| 陵川县| 宁武县| 枝江市| 铜鼓县| 仙游县| 汤原县| 永和县| 子长县| 遵义县| 青州市| 尚志市| 钟祥市| 柏乡县| 江达县| 宣恩县| 高雄市| 龙门县| 乌拉特中旗| 饶平县| 兖州市| 涞水县| 当阳市| 崇礼县| 长兴县| 贵定县| 鸡泽县| 大荔县| 浦江县| 赤壁市| 滨海县| 夏河县| 讷河市| 安国市| 江陵县| 惠安县| 商城县|