mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
23 lines
1.0 KiB
HTML
23 lines
1.0 KiB
HTML
|
<p>Given an integer array <code>nums</code> and two integers <code>k</code> and <code>t</code>, return <code>true</code> if there are <strong>two distinct indices</strong> <code>i</code> and <code>j</code> in the array such that <code>abs(nums[i] - nums[j]) <= t</code> and <code>abs(i - j) <= k</code>.</p>
|
||
|
|
||
|
<p> </p>
|
||
|
<p><strong>Example 1:</strong></p>
|
||
|
<pre><strong>Input:</strong> nums = [1,2,3,1], k = 3, t = 0
|
||
|
<strong>Output:</strong> true
|
||
|
</pre><p><strong>Example 2:</strong></p>
|
||
|
<pre><strong>Input:</strong> nums = [1,0,1,1], k = 1, t = 2
|
||
|
<strong>Output:</strong> true
|
||
|
</pre><p><strong>Example 3:</strong></p>
|
||
|
<pre><strong>Input:</strong> nums = [1,5,9,1,5,9], k = 2, t = 3
|
||
|
<strong>Output:</strong> false
|
||
|
</pre>
|
||
|
<p> </p>
|
||
|
<p><strong>Constraints:</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li><code>1 <= 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>
|
||
|
</ul>
|