Skip to content

Practice XOR Operation in an Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1486
LeetCode Problem

XOR Operation in an Array

Problem Statement

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.

Source: XOR Operation in an Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 5, start = 0
Output
8

# Example 2

Input
n = 4, start = 3
Output
8

Constraints

1 <= n <= 1000
0 <= start <= 1000
n == nums.length

Related LeetCode Problems

Practice more problems similar to XOR Operation in an Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.