# Flip Bit to Win

Posted: 7 Mar, 2021
Difficulty: Easy

## PROBLEM STATEMENT

#### Note:

``````You may also choose not to plant that extra tree at all.
``````
##### For Example:
``````Input: 54
Output: 5

The binary representation of 54 is 110110.
After flipping the third bit from the left, we get consecutive 5 bits. i.e. 111110.
``````
##### Input format:
``````The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the 'T' test cases are as follows.

The first and the only line of each test contains an integer 'N', denoting the integer whose consecutive ones in the binary representation are to be found out.
``````
##### Output format:
``````For the integer, print the length of the longest sequence of 1 s you could create by flipping exactly one bit.

Output for each test case will be printed in a separate line.
``````
##### Note:
``````You do not need to print anything. It has already been taken care of. Just implement the given function.
``````
##### Constraints:
``````1 <= T <= 1000
2 <= N <= 10^9

Where 'N' is the integer that is to be looked into for the maximum consecutive ones after flipping 1 bit.

Time limit: 1 second
``````