231. Power of Two
Given an integer, write a function to determine if it is a power of two.
Example 1:
Example 2:
Example 3:
Thoughts:
Power of 2 means only one bit of n is '1', so use the trick n& (n-1)==0 to judge whether that is the case
Last updated
Was this helpful?