XOR the Arithmetic-Step Array
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
Define n values nums[i]=start+2*i for zero-based indices 0..n-1. Return their bitwise XOR.
```cpp
class Solution {
public:
int xorOperation(int n, int start);
};
```
### Examples
**Example 1:**
```text
Input: n = 3, start = 2
Output: 0
Explanation: The values are2,4,6,and2 XOR4 XOR6 is0.
```
**Example 2:**
```text
Input: n = 1, start = 9
Output: 9
Explanation: The single value is9.
```
### Constraints
- `1 <= n <= 1000` and `0 <= start <= 1000`.
- The defined array has length n.
### Contract considerations
The array is defined implicitly; materializing it is optional.
```hint Read the boundary condition
Check the first and last generated terms and a zero starting value. The requested operation is bitwise XOR.
```
### Boundary reminders
The array is defined implicitly; materializing it is optional.
Overview: XOR the Arithmetic-Step Array. Define n values nums[i]=start+2*i for zero-based indices0..n-1. Return their bitwise XOR.