XOR of numbers
Practice
3 (9 votes)
Bit manipulation
Basic programming
Bitmask
Prefix
Basics of bit manipulation
Problem
47% Success 2159 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given an array $$a$$ of $$n$$ numbers and $$q$$ queries. In each query, $$l$$, $$r$$ find $$XOR$$ of all $$n$$ numbers except the range $$[l, r]$$.
Input format
- The first line contains two integers $$n$$ denoting the number of elements and $$q$$ denoting the number of test cases.
- The second line of each test case contains $$n$$ space-separated integers.
- The next $$q$$ lines contain two integers $$l$$ and $$r$$.
Output format
For each test case, print the answer as described in the problem statement.
Example
Let the array $$a$$ be $$[1, 2, 3, 4]$$ and you are given a query $$(2, 3)$$, then print the $${XOR}$$ of all the array $$a$$ without the range $$[2, 3]$$.
Hence, the answer will be $$1 $${XOR}$$ 4$$.
Constraints
$$1 \le n \le 10^5$$
$$1 \le q \le {10^5}$$
$$1 \le a_i \le {10^9}$$
$$1 \le l, r \le n$$
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
69 votes
Tags:
Bit ManipulationBasic ProgrammingBasics of bit manipulationXORBasics of Bit Manipulation
Points:30
67 votes
Tags:
Basic ProgrammingBit Manipulation
Points:30
20 votes
Tags:
Bit ManipulationBasic ProgrammingBasics of Bit Manipulation
Editorial
Login to unlock the editorial