263-Ugly-Number

Sat 17 May 2025

https://leetcode.com/problems/ugly-number

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def isUgly(self, n: int) -> bool:
    if n == 0:
      return False

    for prime in 2, 3, 5:
      while n % prime == 0:
        n //= prime

    return n == 1
new Solution().isUgly()

Score: 5

Category: leetcode