Is it possible?

Revision en1, by tautology, 2018-01-26 23:48:29

Given array of n non-negative integers and a positive integer k. Is is possible to count all pairs with bitwise-OR equals to k?. Time complexity should be better than O(n^2). More formally , count no. of distinct pairs (ai,aj) such that ai|aj==k.[Note: pairs (ai,aj) and (aj,ai) are same.] If this is possible in T(n)<O(n^2),then how? Constraints: 1<=n<=1000000, 0<=ai<=10000.

Tags #bitwiseor, #help


  Rev. Lang. By When Δ Comment
en1 English tautology 2018-01-26 23:48:29 402 Initial revision (published)