无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

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

LeetCode 2718. Sum of Matrix After Queries

2023-06-04 13:28 作者:您是打尖兒還是住店呢  | 我要投稿

You are given an integer?n?and a?0-indexed?2D array?queries?where?queries[i] = [typei, indexi, vali].

Initially, there is a?0-indexed?n x n?matrix filled with?0's. For each query, you must apply one of the following changes:

  • if?typei?== 0, set the values in the row with?indexi?to?vali, overwriting any previous values.

  • if?typei?== 1, set the values in the column with?indexi?to?vali, overwriting any previous values.

Return?the sum of integers in the matrix after all queries are applied.

?

Example 1:

Input: n = 3, queries = [[0,0,1],[1,2,2],[0,2,3],[1,0,4]]Output: 23Explanation: The image above describes the matrix after each query. The sum of the matrix after all queries are applied is 23.

Example 2:

Input: n = 3, queries = [[0,0,4],[0,1,2],[1,0,1],[0,2,3],[1,2,1]]Output: 17Explanation: The image above describes the matrix after each query. The sum of the matrix after all queries are applied is 17.

最后一次會有影響,所以我們用hashmap去保存最后的數(shù)據(jù),那么就要減減循環(huán)了。

然后依次累加。


Runtime:?24 ms, faster than?20.00%?of?Java?online submissions for?Sum of Matrix After Queries.

Memory Usage:?70.8 MB, less than?20.00%?of?Java?online submissions for?Sum of Matrix After Queries.


LeetCode 2718. Sum of Matrix After Queries的評論 (共 條)

分享到微博請遵守國家法律
承德县| 酒泉市| 漯河市| 鸡泽县| 色达县| 思南县| 陇川县| 佳木斯市| 中牟县| 奇台县| 开原市| 鹤壁市| 永年县| 含山县| 巴南区| 太仓市| 桐乡市| 武功县| 茌平县| 台南市| 长子县| 山阳县| 石景山区| 巫溪县| 辽阳市| 呈贡县| 嘉禾县| 松溪县| 武穴市| 锡林郭勒盟| 河北省| 汾阳市| 吉木萨尔县| 通城县| 玉田县| 上思县| 泸西县| 酒泉市| 济宁市| 梧州市| 辽宁省|