Sir whhat is the need of loop here we can simply do it by if statements

sir whhat is the need of loop here we can simply do it by if statements

@Aditya-Kushwaha-914550392281281

loop is require to fill dp array for all i from 0 to n

and at end we have to return dp[n]
but for that we require all previous value so we have to make dp array
and for this we need loop

and how can you do it by only if statement???

i hope you understand
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course

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.