1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/找出顶峰元素 II [find-a-peak-element-ii].html
2022-03-29 12:43:11 +08:00

44 lines
1.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>一个 2D 网格中的 <strong>顶峰元素 </strong>是指那些 <strong>严格大于 </strong>其相邻格子(上、下、左、右)的元素。</p>
<p>给你一个<strong> 从 0 开始编号 </strong><code>m x n</code> 矩阵 <code>mat</code> ,其中任意两个相邻格子的值都<strong> 不相同</strong> 。找出 <strong>任意一个 </strong>顶峰元素 <code>mat[i][j]</code><strong>返回其位置 </strong><code>[i,j]</code></p>
<p>你可以假设整个矩阵周边环绕着一圈值为 <code>-1</code> 的格子。</p>
<p>要求必须写出时间复杂度为 <code>O(m log(n))</code><code>O(n log(m))</code> 的算法</p>
<p> </p>
<p> </p>
<p><strong>示例 1:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/06/08/1.png" style="width: 206px; height: 209px;" /></p>
<pre>
<strong>输入:</strong> mat = [[1,4],[3,2]]
<strong>输出:</strong> [0,1]
<strong>解释:</strong> 3和4都是顶峰元素所以[1,0]和[0,1]都是可接受的答案。
</pre>
<p><strong>示例 2:</strong></p>
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2021/06/07/3.png" style="width: 254px; height: 257px;" /></strong></p>
<pre>
<strong>输入:</strong> mat = [[10,20,15],[21,30,14],[7,16,32]]
<strong>输出:</strong> [1,1]
<strong>解释:</strong> 30和32都是顶峰元素所以[1,1]和[2,2]都是可接受的答案。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == mat.length</code></li>
<li><code>n == mat[i].length</code></li>
<li><code>1 <= m, n <= 500</code></li>
<li><code>1 <= mat[i][j] <= 10<sup>5</sup></code></li>
<li>任意两个相邻元素均不相等.</li>
</ul>