Shubham and Xor
Practice
3.6 (49 votes)
Algorithms
Bubble sort algorithm
Easy
Searching
Sorting
Problem
84% Success 29185 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given an array of n integer numbers \(a_1\), \(a_2\), .. ,\(a_n\). Calculate the number of pair of indices \((i,j)\) such that \(1\le i\) < \( j\le n\) and \(a_i\) xor \(a_j = 0\)
Input format
- First line: n denoting the number of array elements
- Second line: n space separated integers \(a_1\), \(a_2\), .. ,\(a_n\).
Output format
Output the required number of pairs.
Constraints
\(1\le n\le 10^6\)
\(1 \le a_i \le 10^9\)
Sample Input
5 1 3 1 4 3
Sample Output
2
Explanation
The 2 pair of indices are \((1,3)\) and \((2,5)\) .
Code Editor
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
Submissions
Please login to view your submissions
Similar Problems
Points:20
76 votes
Tags:
AlgorithmsBasic ProgrammingBubble SortInput/OutputSorting
Points:20
137 votes
Tags:
Ad-HocEasySorting
Points:20
81 votes
Tags:
Basic ProgrammingBrute-force searchBubble sort algorithmEasySorting
Editorial
Login to unlock the editorial
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