sir why the condition is
opt=dp[i/3] or opt= dp[i/2]??
not opt=dp[num/2] or opt=dp[num/3]?!
Minimum step to one(dynammic programming)
Because whenever we do, num/3 or num/2 it become i, and after that we compute on that i only, instead of num.
so, it will be correct to define it like this.
dp[i]=dp[i-1]+1;
if(i%2==0)dp[i]=min(dp[i],dp[i/2]+1);
if(i%3==0)dp[i]=min(dp[i],dp[i/3]+1);