You are given an integer n and an integer start. Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums.
You are given an integer n and an integer start. Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums.
Example 1:
Input: {"n":5,"start":0}
Output: 8
Constraints:
1≤n≤1000
0≤start≤1000
n==nums.length
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":5,"start":0}
nums holds 5 values: 0, 2, 4, ... each 2 apart. Start with result = 0, since x ^ 0 = x.