mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 10:51:42 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,34 +1,44 @@
|
||||
<p>给你一个整数数组 <code>nums</code> 和两个整数 <code>k</code> 和 <code>t</code> 。请你判断是否存在 <b>两个不同下标</b> <code>i</code> 和 <code>j</code>,使得 <code>abs(nums[i] - nums[j]) <= t</code> ,同时又满足 <code>abs(i - j) <= k</code><em> </em>。</p>
|
||||
<p>给你一个整数数组 <code>nums</code> 和两个整数 <code>indexDiff</code> 和 <code>valueDiff</code> 。</p>
|
||||
|
||||
<p>如果存在则返回 <code>true</code>,不存在返回 <code>false</code>。</p>
|
||||
<p>找出满足下述条件的下标对 <code>(i, j)</code>:</p>
|
||||
|
||||
<p> </p>
|
||||
<ul>
|
||||
<li><code>i != j</code>,</li>
|
||||
<li><code>abs(i - j) <= indexDiff</code></li>
|
||||
<li><code>abs(nums[i] - nums[j]) <= valueDiff</code></li>
|
||||
</ul>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
<p>如果存在,返回 <code>true</code><em> ;</em>否则,返回<em> </em><code>false</code><em> </em>。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong class="example">示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>nums = [1,2,3,1], k<em> </em>= 3, t = 0
|
||||
<strong>输出:</strong>true</pre>
|
||||
<strong>输入:</strong>nums = [1,2,3,1], indexDiff = 3, valueDiff = 0
|
||||
<strong>输出:</strong>true
|
||||
<strong>解释:</strong>可以找出 (i, j) = (0, 3) 。
|
||||
满足下述 3 个条件:
|
||||
i != j --> 0 != 3
|
||||
abs(i - j) <= indexDiff --> abs(0 - 3) <= 3
|
||||
abs(nums[i] - nums[j]) <= valueDiff --> abs(1 - 1) <= 0
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
<p><strong class="example">示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>nums = [1,0,1,1], k<em> </em>=<em> </em>1, t = 2
|
||||
<strong>输出:</strong>true</pre>
|
||||
<strong>输入:</strong>nums = [1,5,9,1,5,9], indexDiff = 2, valueDiff = 3
|
||||
<strong>输出:</strong>false
|
||||
<strong>解释:</strong>尝试所有可能的下标对 (i, j) ,均无法满足这 3 个条件,因此返回 false 。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>nums = [1,5,9,1,5,9], k = 2, t = 3
|
||||
<strong>输出:</strong>false</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>0 <= nums.length <= 2 * 10<sup>4</sup></code></li>
|
||||
<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>
|
||||
<li><code>0 <= k <= 10<sup>4</sup></code></li>
|
||||
<li><code>0 <= t <= 2<sup>31</sup> - 1</code></li>
|
||||
<li><code>2 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
<li><code>1 <= indexDiff <= nums.length</code></li>
|
||||
<li><code>0 <= valueDiff <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user