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)/质数的最大距离 [maximum-prime-difference].html
2024-04-30 10:04:49 +08:00

36 lines
1.2 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>nums</code></p>
<p>返回两个(不一定不同的)质数在 <code>nums</code>&nbsp;<strong>下标</strong><strong>最大距离</strong></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [4,2,9,5,3]</span></p>
<p><strong>输出:</strong> <span class="example-io">3</span></p>
<p><strong>解释:</strong> <code>nums[1]</code><code>nums[3]</code><code>nums[4]</code> 是质数。因此答案是 <code>|4 - 1| = 3</code></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [4,8,2,8]</span></p>
<p><strong>输出:</strong> <span class="example-io">0</span></p>
<p><strong>解释:</strong> <code>nums[2]</code> 是质数。因为只有一个质数,所以答案是 <code>|2 - 2| = 0</code></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 3 * 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
<li>输入保证 <code>nums</code> 中至少有一个质数。</li>
</ul>