mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
44 lines
1.5 KiB
HTML
44 lines
1.5 KiB
HTML
<p>给你一个 <code>m x n</code> 的矩阵 <code>M</code><strong> </strong>和一个操作数组 <code>op</code> 。矩阵初始化时所有的单元格都为 <code>0</code> 。<code>ops[i] = [ai, bi]</code> 意味着当所有的 <code>0 <= x < ai</code> 和 <code>0 <= y < bi</code> 时, <code>M[x][y]</code> 应该加 1。</p>
|
||
|
||
<p>在 <em>执行完所有操作后</em> ,计算并返回 <em>矩阵中最大整数的个数</em> 。</p>
|
||
|
||
<p> </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 = 3,ops = [[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> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<p><meta charset="UTF-8" /></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= m, n <= 4 * 10<sup>4</sup></code></li>
|
||
<li><code>0 <= ops.length <= 10<sup>4</sup></code></li>
|
||
<li><code>ops[i].length == 2</code></li>
|
||
<li><code>1 <= a<sub>i</sub> <= m</code></li>
|
||
<li><code>1 <= b<sub>i</sub> <= n</code></li>
|
||
</ul>
|