mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			1005 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1005 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>You are given an integer <code>n</code> and an integer <code>start</code>.</p>
 | 
						|
 | 
						|
<p>Define an array <code>nums</code> where <code>nums[i] = start + 2 * i</code> (<strong>0-indexed</strong>) and <code>n == nums.length</code>.</p>
 | 
						|
 | 
						|
<p>Return <em>the bitwise XOR of all elements of</em> <code>nums</code>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> n = 5, start = 0
 | 
						|
<strong>Output:</strong> 8
 | 
						|
<strong>Explanation:</strong> Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
 | 
						|
Where "^" corresponds to bitwise XOR operator.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> n = 4, start = 3
 | 
						|
<strong>Output:</strong> 8
 | 
						|
<strong>Explanation:</strong> Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= n <= 1000</code></li>
 | 
						|
	<li><code>0 <= start <= 1000</code></li>
 | 
						|
	<li><code>n == nums.length</code></li>
 | 
						|
</ul>
 |