Maximize OR
Basic Accuracy: 22.22% Submissions: 18 Points: 1

Given a number X find the total numbers A such that A OR X > X,  and 1<=A<=X.

Example 1:

Input: X = 10
Output: 7 
Explanation: In the range [1,10] if the 
OR is taken of 10 and any number in the 
set {1,3,4,5,6,7,9} the resulting value 
will be greater than 10.

Example 2:

Input: X = 5
Output: 2
Explanation: In the range [1,5] if the
OR is taken of 5 and any number in the
set {2,3} the resulting value
will be greater than 5.


Your Task:  
You dont need to read input or print anything. Complete the function getCount() which takes X as input parameter and returns the the total count of the different value of A possible.

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

Constraints:
1<= X <=108

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