Leet code question 263 ugly numbers
Anonymous
class Solution { public: bool isUgly(int n) { if (n 1) { if (n % 2 == 0) n = n / 2; else if (n % 3 == 0) n = n / 3; else if (n % 5 == 0) n = n / 5; else break; } return (n == 1); } };
Check out your Company Bowl for anonymous work chats.