Hi everyone, recenetly there was a hiring [challenge](https://www.hackerearth.com/challenges/hiring/jpmc-se-2019/) by JP Morgan on HackerEarth, and this problem was there. <br> ↵
**Problem statement :** <br>↵
Given an array of N integers and an integer k, <br>↵
let cnt1 = no. of subsets of array whose XOR is less than k, <br>↵
cnt2 = no. of subsets of array whose XOR is equal to k, and <br>↵
cnt3 = no. of subsets of array whose XOR is greater than k. <br> <br>↵
↵
You have to print value of expression : (cnt1 * cnt2) + (cnt2 * cnt3) + (cnt3 * cnt1) — (cnt1 + cnt2 + cnt3)<sup>2</sup> . <br> <br>↵
**Constraints :** <br>↵
1 <= N, k, A[i] <= 100000.↵
↵
<br> ↵
There is O(maxVal * N) [solution](https://www.geeksforgeeks.org/count-number-of-subsets-having-a-particular-xor-value/) but obviously it's not feasible for given constraints. How to solve it with better time/space complexity ? <br>↵
**Edit:** We had to print exp % 10<sup>9</sup> + 7.
**Problem statement :** <br>↵
Given an array of N integers and an integer k, <br>↵
let cnt1 = no. of subsets of array whose XOR is less than k, <br>↵
cnt2 = no. of subsets of array whose XOR is equal to k, and <br>↵
cnt3 = no. of subsets of array whose XOR is greater than k. <br> <br>↵
↵
You have to print value of expression : (cnt1 * cnt2) + (cnt2 * cnt3) + (cnt3 * cnt1) — (cnt1 + cnt2 + cnt3)<sup>2</sup> . <br> <br>↵
**Constraints :** <br>↵
1 <= N, k, A[i] <= 100000.↵
↵
<br> ↵
There is O(maxVal * N) [solution](https://www.geeksforgeeks.org/count-number-of-subsets-having-a-particular-xor-value/) but obviously it's not feasible for given constraints. How to solve it with better time/space complexity ? <br>↵
**Edit:** We had to print exp % 10<sup>9</sup> + 7.