国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

LeetCode 2679. Sum in a Matrix

2023-05-21 15:52 作者:您是打尖兒還是住店呢  | 我要投稿

You are given a?0-indexed?2D integer array?nums. Initially, your score is?0. Perform the following operations until the matrix becomes empty:

  1. From each row in the matrix, select the largest number and remove it. In the case of a tie, it does not matter which number is chosen.

  2. Identify the highest number amongst all those removed in step 1. Add that number to your?score.

Return?the final?score.

?

Example 1:

Input: nums = [[7,2,1],[6,4,2],[6,5,3],[3,2,1]]

Output: 15

Explanation: In the first operation, we remove 7, 6, 6, and 3. We then add 7 to our score. Next, we remove 2, 4, 5, and 2. We add 5 to our score. Lastly, we remove 1, 2, 3, and 1. We add 3 to our score. Thus, our final score is 7 + 5 + 3 = 15.

Example 2:

Input: nums = [[1]]Output: 1

Explanation: We remove 1 and add it to the answer. We return 1.

?

給你一個(gè)下標(biāo)從 0 開始的二維整數(shù)數(shù)組 nums 。一開始你的分?jǐn)?shù)為 0 。你需要執(zhí)行以下操作直到矩陣變?yōu)榭眨?/p>


矩陣中每一行選取最大的一個(gè)數(shù),并刪除它。如果一行中有多個(gè)最大的數(shù),選擇任意一個(gè)并刪除。

在步驟 1 刪除的所有數(shù)字中找到最大的一個(gè)數(shù)字,將它添加到你的 分?jǐn)?shù) 中。

請(qǐng)你返回最后的 分?jǐn)?shù) 。

可以先將每一行數(shù)組進(jìn)行排序,然后依次求出每一列的最大值,sum求和記錄即可;


Runtime:?16 ms, faster than?88.62%?of?Java?online submissions for?Sum in a Matrix.

Memory Usage:?57 MB, less than?99.68%?of?Java?online submissions for?Sum in a Matrix.


LeetCode 2679. Sum in a Matrix的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
巴楚县| 濮阳市| 迭部县| 靖远县| 巩义市| 德兴市| 曲阳县| 高尔夫| 凤翔县| 漾濞| 连平县| 招远市| 长宁县| 赫章县| 海南省| 台山市| 喀什市| 肇州县| 石楼县| 冷水江市| 平定县| 高青县| 阜平县| 枝江市| 江口县| 定南县| 竹北市| 抚宁县| 广州市| 冕宁县| 塘沽区| 宜丰县| 交口县| 博罗县| 仁化县| 皮山县| 阿荣旗| 新晃| 黑河市| 昌宁县| 东阳市|