Bitwise AND problem by Google-intern
Anonymous User
985

You are given n positions and each positions has a value associated with it. You can delete two positions but there Bitwise And operation of two values should be greater than K. Find the number of pair of positions whose BitWise AND value is greater than K .
Input Format:
First line: N value
Second line: N space seperated integers
Third line: K value
Input:
3
1 2 3
0
Output:
2

constraints:
2<= n <= 5*10^(5)
0<= k <=10^(3)

Can any one solve this problem and share the code in comment below as I got Time limt exceeded?

Note: : No explanation is given by that company assement regarding the optimised way to do, can any one tell ?

Comments (6)