You have an integer and you can flip exactly one bit from a 0 to a 1. Write code to find the length of the longest sequence of 1s you could create.
Example 1:
Input: num
= 1775(110111011112)
Output: 8
Example 2:
Input: num
= 7(01112)
Output: 4