low
as the minimum of a
, b
, c
, and high
as a sufficiently large number (e.g., 2 * 10^9
).countUglyNumbers
that takes an integer num
and returns the count of ugly numbers less than or equal to num
using the principle of inclusion-exclusion.low
is less than high
:
mid
as the average of low
and high
.countUglyNumbers(mid)
is greater than or equal to n
, update high
to mid
.low
to mid + 1
.low
as the nth ugly number.