mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										32
									
								
								算法题(国外版)/contains-duplicate-ii.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								算法题(国外版)/contains-duplicate-ii.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <code>true</code> if there are two <strong>distinct indices</strong> <code>i</code> and <code>j</code> in the array such that <code>nums[i] == nums[j]</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
 | 
			
		||||
<strong>Output:</strong> true
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,0,1,1], k = 1
 | 
			
		||||
<strong>Output:</strong> true
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 3:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,2,3,1,2,3], k = 2
 | 
			
		||||
<strong>Output:</strong> false
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
 | 
			
		||||
	<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
 | 
			
		||||
	<li><code>0 <= k <= 10<sup>5</sup></code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user