week27
263 - 丑数
class Solution {
public:
bool isUgly(int x) {
if(x <= 0) return false;
// 只包含 质因数 2 3 5 的数字 -> 除干净
while(x % 2 == 0) x /= 2;
while(x % 3 == 0) x /= 3;
while(x % 5 == 0) x /= 5;
return x == 1;
}
};264 - 丑数II
268 - 丢失的数字
Last updated