Can i just get some hint insight on how to write code for this?I tried a dry run for the prob then just trying to see some pattern.
Can i just get some hint insight on how to write code for this?
Hi @pranjalarora98 approach for this question will be like
if i is even
dp[i]= min(dp[i/2]+x,dp[i-1]+y} ;
if i is odd
dp[i]=min(dp[i-1]+y,dp[i+1/2]+x+z} ;
For code reference you can see this
If this solves your query, please mark it as resolved.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.