XOR-ing the Subarrays! - InterviewBit Solution

Problem: XOR-ing the Subarrays!


Problem Description

Given an integer array A of size N. You need to find the value obtained by XOR-ing the contiguous subarrays, followed by XOR-ing the values thus obtained. Determine and return this value. For example, if A = [3, 4, 5] :

Subarray    Operation   Result
3       None            3
4       None            4
5       None            5
3,4   3 XOR 4         7
4,5   4 XOR 5         1
3,4,5    3 XOR 4 XOR 5   2

Problem Constraints

1 <= N <= 105
1 <= A[i] <= 108

Input Format

The first and only argument is an integer array A.


Output Format

Return a single integer denoting the value as described above.


Solution Approach:



Solution in CPP:


If you have any questions or queries, feel free to drop a comment in the comments section below.

Note: Help us improve this blog

If you have a better solution, and you think you can help your peers to understand this problem better, then please drop your solution and approach in the comments section below.

We will upload your approach and solution here by giving you the proper credit so that you can showcase it among your peers.