{"id":"53a17151-6357-4b6f-b9a6-056022ae0db2","name":"Count Zeros Xor Pairs","description":"1. Given an array A[] of size N. \r\n2. Find the number of pairs (i, j) such that A[i] XOR A[j] = 0, and 1 <= i < j <= N.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":"2 &lt;= N &lt;= 10^5\r\n1 &lt;= A[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <vector>\n#include <unordered_map>\nusing namespace std;\n\nint countPairs(vector<int> &arr) {\n //write your code here\n return 0;\n}\n\nint main() {\n //input work\n int n = 0;\n cin>>n;\n vector<int> arr(n);\n for (int i = 0; i < n; i++) {\n cin>>arr[i];\n } \n cout<<countPairs(arr);\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n public static int countPairs(int[]arr) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[]arr = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n System.out.println(countPairs(arr));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\n1 3 1 3 1 1","sampleOutput":"7","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"c3f03697-add9-4bf0-bfc9-37c52ba816ac","name":"Count Zeros Xor Pairs","slug":"count-zeros-xor-pairs","type":1}],"next":{"id":"6632a4a0-1862-424b-b29e-1f13c0f431c5","name":"Count Zeros Xor Pairs","type":3,"slug":"count-zeros-xor-pairs"},"prev":{"id":"662b8f58-3f7d-44c3-b145-4788d473385c","name":"Counting Elements In Two Arrays MCQ","type":0,"slug":"counting-elements-in-two-arrays-mcq"}}}

Count Zeros Xor Pairs

1. Given an array A[] of size N. 2. Find the number of pairs (i, j) such that A[i] XOR A[j] = 0, and 1 <= i < j <= N.

{"id":"53a17151-6357-4b6f-b9a6-056022ae0db2","name":"Count Zeros Xor Pairs","description":"1. Given an array A[] of size N. \r\n2. Find the number of pairs (i, j) such that A[i] XOR A[j] = 0, and 1 <= i < j <= N.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":"2 &lt;= N &lt;= 10^5\r\n1 &lt;= A[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <vector>\n#include <unordered_map>\nusing namespace std;\n\nint countPairs(vector<int> &arr) {\n //write your code here\n return 0;\n}\n\nint main() {\n //input work\n int n = 0;\n cin>>n;\n vector<int> arr(n);\n for (int i = 0; i < n; i++) {\n cin>>arr[i];\n } \n cout<<countPairs(arr);\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n public static int countPairs(int[]arr) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[]arr = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n System.out.println(countPairs(arr));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\n1 3 1 3 1 1","sampleOutput":"7","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"c3f03697-add9-4bf0-bfc9-37c52ba816ac","name":"Count Zeros Xor Pairs","slug":"count-zeros-xor-pairs","type":1}],"next":{"id":"6632a4a0-1862-424b-b29e-1f13c0f431c5","name":"Count Zeros Xor Pairs","type":3,"slug":"count-zeros-xor-pairs"},"prev":{"id":"662b8f58-3f7d-44c3-b145-4788d473385c","name":"Counting Elements In Two Arrays MCQ","type":0,"slug":"counting-elements-in-two-arrays-mcq"}}}
plane

Editor


Loading...

Count Zeros Xor Pairs

easy

1. Given an array A[] of size N. 2. Find the number of pairs (i, j) such that A[i] XOR A[j] = 0, and 1

Constraints

2 <= N <= 10^5 1 <= A[i] <= 10^5

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

6 1 3 1 3 1 1

Sample Output

7

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode