342.Power of Four
示例 1:
输入: 16
输出: true
示例 2:
输入: 5
输出: false
进阶:
你能不使用循环或者递归来完成本题吗?class Solution {
unordered_set<int> powers={1,4,16,64,256,1024,4096,16384 ,65536,262144,1048576, 4194304, 16777216,67108864, 268435456, 1073741824};
public:
bool isPowerOfFour(int num) {
return powers.count(num);
}
};Last updated