nums
with a size of 1690 and set the first element to 1 (the first ugly number).i2
, i3
, and i5
to 0, which will track the position of the last number multiplied by 2, 3, and 5, respectively.nums
array with ugly numbers.nums[i2] * 2
, nums[i3] * 3
, and nums[i5] * 5
.nums
array.i2
, i3
, or i5
) that corresponds to the minimum number chosen.nums
array.