[LintCode]O(1) Check Power of 2
class Solution {
/*
* @param n: An integer
* @return: True or false
*/
public boolean checkPowerOf2(int n) {
// 2015-09-06
if (n <= 0) {
return false;
}
boolean res = ((n & (n-1)) == 0) ? true : false;
return res;
}
};