Python This should be 2 pointer problem instead of DP
\ndef nthUglyNumber(self, n: int) -> int:\n    """\n        Think about array \n        a, b, c, d ,e\n        for every element , could multiply by 2, 3, 5 the
```\ndef nthUglyNumber(self, n: int) -> int:\n    """\n        Think about array \n        a, b, c, d ,e\n        for every element , could multiply by 2, 3, 5 then become new array\n        2*a, 2*b, 2*c ...3*a, 3*b, 3*c ...5*a ,5*b\n        but we want to nth ugly number, the result is not sorted , it could be \n        2*a, 1*c, 2*b, 3*a ....\n        To make sure the array is sorted while expanding. Could use 3 index to track when\n        multiply by 2,3,5. everytime , we want to add the min value\n        \n        Sample :\n        i2=i3=i5=0, arr=[1], n=5\n        1\n        <-----i2,i3,i5.  min(arr[i2]*2, arr[i2]*3, arr[i5]*5) = 2  use i2. i2+=1\n        1, 2\n           <-----i2 .  min(arr[i2]*2, arr[i3]*3, arr[i5]*5) = 3  use i3. i3+=1\n        <-----i3,i5\n        1, 2, 3\n           <------i2,i3 min(arr[i2]*2, arr[i3]*3, arr[i5]*5) = 4. use i2. i2+=1\n        <---------i5\n        1, 2, 3, 4\n              <---i2    min(arr[i2]*2, arr[1]*3, arr[0]*5) = 5. use i5. i5+=1\n           <------i3\n        <---------i5\n        1, 2, 3, 4, 5\n    """\n    i2,i3,i5=0,0,0\n\tarr = [1]\n\twhile len(arr) < n:\n\t\tv2,v3,v5 = arr[i2]*2, arr[i3]*3, arr[i5]*5\n\t\tm = min(v2,v3,v5)\n\t\tif m == v2:\n\t\t\ti2+=1\n\t\tif m == v3:\n\t\t\ti3+=1\n\t\tif m == v5:\n\t\t\ti5+=1\n\t\tarr.append(m)\n\treturn arr[-1]\n```
[]