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)/与对应负数同时存在的最大正整数 [largest-positive-integer-that-exists-with-its-negative].html
2022-10-20 22:28:17 +08:00

40 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>给你一个 <strong>不包含</strong> 任何零的整数数组 <code>nums</code> ,找出自身与对应的负数都在数组中存在的最大正整数 <code>k</code></p>
<p>返回正整数<em> </em><code>k</code> ,如果不存在这样的整数,返回 <code>-1</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [-1,2,-3,3]
<strong>输出:</strong>3
<strong>解释:</strong>3 是数组中唯一一个满足题目要求的 k 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [-1,10,6,7,-7,1]
<strong>输出:</strong>7
<strong>解释:</strong>数组中存在 1 和 7 对应的负数7 的值更大。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [-10,8,6,7,-2,-3]
<strong>输出:</strong>-1
<strong>解释:</strong>不存在满足题目要求的 k ,返回 -1 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 1000</code></li>
<li><code>-1000 &lt;= nums[i] &lt;= 1000</code></li>
<li><code>nums[i] != 0</code></li>
</ul>