Tiger's leetcode solution
Tuesday, July 7, 2015
Power of Two
Q:
Given an integer, write a function to determine if it is a power of two.
A:
public class Solution { public boolean isPowerOfTwo(int n) { return n>0 && (n & (n-1))==0; } }
Mistakes:
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment