mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	add scripts and problemset
This commit is contained in:
		
							
								
								
									
										42
									
								
								算法题/count-pairs-with-xor-in-a-range.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								算法题/count-pairs-with-xor-in-a-range.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
<p>Given a <strong>(0-indexed)</strong> integer array <code>nums</code> and two integers <code>low</code> and <code>high</code>, return <em>the number of <strong>nice pairs</strong></em>.</p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<p>A <strong>nice pair</strong> is a pair <code>(i, j)</code> where <code>0 <= i < j < nums.length</code> and <code>low <= (nums[i] XOR nums[j]) <= high</code>.</p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
 | 
			
		||||
<strong>Input:</strong> nums = [1,4,2,7], low = 2, high = 6
 | 
			
		||||
 | 
			
		||||
<strong>Output:</strong> 6
 | 
			
		||||
 | 
			
		||||
<strong>Explanation:</strong> All nice pairs (i, j) are as follows:
 | 
			
		||||
 | 
			
		||||
    - (0, 1): nums[0] XOR nums[1] = 5 
 | 
			
		||||
 | 
			
		||||
    - (0, 2): nums[0] XOR nums[2] = 3
 | 
			
		||||
 | 
			
		||||
    - (0, 3): nums[0] XOR nums[3] = 6
 | 
			
		||||
 | 
			
		||||
    - (1, 2): nums[1] XOR nums[2] = 6
 | 
			
		||||
 | 
			
		||||
    - (1, 3): nums[1] XOR nums[3] = 3
 | 
			
		||||
 | 
			
		||||
    - (2, 3): nums[2] XOR nums[3] = 5
 | 
			
		||||
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user