Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6564 |

@blackshadows | 6400 |

@mb1973 | 5785 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4639 |

@sanjay05 | 3762 |

@mantu_singh | 3712 |

@gfgaccount | 3627 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@yaswanthero123 | 625 |

@vikash619 | 611 |

@venkat11803610 | 501 |

@roshan13ar | 396 |

@DevangSingh | 379 |

@ravi11815721 | 312 |

@hrishipangavhane | 286 |

@aryanjain85297 | 280 |

@kommaraju11806903 | 277 |

@infosumitraut | 272 |

@ankitsharma5422 | 256 |

Complete Leaderboard |

Given an array A[] of size N. Find the number of pairs (i, j) such that

A_{i }XOR A_{j} = 0, and 1 ≤ i < j ≤ N.

**Example 1:**

**â€‹Input :** arr[ ] = {1, 3, 4, 1, 4}
**Output :** 2
**Explanation:**
Index( 0, 3 ) and (2 , 4 ) are only pairs
whose xors is zero so count is 2.

**â€‹Example 2:**

**Input :** arr[ ] = {2, 2, 2} **
Output :** 3

**Your Task:**

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function **calculate()** that takes an array **(arr)**, sizeOfArray **(n)**, and return the count of Zeros Xor's Pairs. The driver code takes care of the printing.

**Expected Time Complexity:** O(N*Log(N)).

**Expected Auxiliary Space:** O(1).

**Output:**

For each test case, output a single integer i.e counts of Zeros Xors Pairs

**Constraints**

2 ≤ N ≤ 10^5

1 ≤ A[i] ≤ 10^5

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Counts Zeros Xor Pairs

...