1
class Solution:
2
def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int:
3
times = [1, 1, 1]
4
smallest = inf
5
while n != 0:
6
smallest = min(times[0] * a, times[1] * b, times[2] * c)
7
if times[0] * a == smallest:
8
times[0] += 1
9
if times[1] * b == smallest:
10
times[1] += 1
11
if times[2] * c == smallest:
12
times[2] += 1
13
n -= 1
14
return smallest

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0