Wrong answer in ugly numbers

given test cases are running correctly but on submission the answer is wrong. Looks correct to me.

You are using a little bit wrong approach, take,
int i2=0,i3=0,i5=0;
long long int next_multiple_2=2;
long long int next_multiple_3=3;
long long int next_multiple_5=5;
long long int dp[n];
dp[0]=1;
long long next_ugly_no=1;
for(int i=1;i<n;i++)
{
next_ugly_no=min(next_multiple_2,min(next_multiple_3,next_multiple_5));
dp[i]=next_ugly_no;
if(next_ugly_no==next_multiple_2)
{
i2++;
next_multiple_2=dp[i2]*2;
}

Repeat the above for i3 and i5, and then try to submit the code.