1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/范围求和 II [range-addition-ii].html
2022-03-29 12:43:11 +08:00

44 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个 <code>m x&nbsp;n</code> 的矩阵&nbsp;<code>M</code><strong>&nbsp;</strong>,初始化时所有的 <code>0</code> 和一个操作数组 <code>op</code> ,其中 <code>ops[i] = [ai, bi]</code> 意味着当所有的 <code>0 &lt;= x &lt; ai</code><code>0 &lt;= y &lt; bi</code> 时, <code>M[x][y]</code> 应该加 1。</p>
<p>&nbsp;<em>执行完所有操作后</em>&nbsp;,计算并返回&nbsp;<em>矩阵中最大整数的个数</em>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/10/02/ex1.jpg" style="height: 176px; width: 750px;" /></p>
<pre>
<strong>输入:</strong> m = 3, n = 3ops = [[2,2],[3,3]]
<strong>输出:</strong> 4
<strong>解释:</strong> M 中最大的整数是 2, 而且 M 中有4个值为2的元素。因此返回 4。
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> m = 3, n = 3, ops = [[2,2],[3,3],[3,3],[3,3],[2,2],[3,3],[3,3],[3,3],[2,2],[3,3],[3,3],[3,3]]
<strong>输出:</strong> 4
</pre>
<p><strong>示例 3:</strong></p>
<pre>
<strong>输入:</strong> m = 3, n = 3, ops = []
<strong>输出:</strong> 9
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<p><meta charset="UTF-8" /></p>
<ul>
<li><code>1 &lt;= m, n &lt;= 4 * 10<sup>4</sup></code></li>
<li><code>0 &lt;= ops.length &lt;= 10<sup>4</sup></code></li>
<li><code>ops[i].length == 2</code></li>
<li><code>1 &lt;= a<sub>i</sub>&nbsp;&lt;= m</code></li>
<li><code>1 &lt;= b<sub>i</sub>&nbsp;&lt;= n</code></li>
</ul>