Power Of 2 and Subsequences
Easy Accuracy: 33.33% Submissions: 9 Points: 2

Given is an array A[] of size N, find all the subsequence which when multiplied results in a number which is Power of 2.

 

Example 1:

Input:
N = 3
A[] = {1, 6, 2}
Output:
3
Explanation:
The subsequence that 
can be chosen is {1},
{2} and {1,2}.

 

 

Example 2:

Input:
N = 3
A[] = {3, 5, 7}
Output:
0
Explanation:
No subsequences exist.

 

 

Your Task:

You don't need to read input or print anything. Your task is to complete the function numberOfSubsequences() which takes an integer N and an array A and returns the number of subsequences that exist. As this number can be very large return the result under modulo 109+7.

 

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

 

 

Constraints:
1 <= N <= 105
1 <= A[i] <= 109

 

to report an issue on this page.

Editorial

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

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window