Check power of two
Java
Easy
5 views
Problem Description
Task: return true if x is power of two.
Output Format
Return value
Constraints
x can be 0 or negative.
Official Solution
static boolean isPowerOfTwo(int x){return x>0 && (x & (x-1))==0;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!