can i do this with dynamic programming

hello everyone…i have just started learning dynamic programming and this is my first ever question attempted…i am facing difficulty in getting the answer.I know this question can be easily done with other method.It will be best if you can let me know if this can be done with the help of Dp or not and if it can be done then how…my BUGGY solution link

Ps-please note that i a beginner.And its my first question in Dp(i think its Dp rest dont know) :smiley: :smiley: :smiley:



It may not require DP, it’s a pure maths logic.Still if you want to do it by using DP, you can memoize the results. If you want DP questions from very basic to very hard, you can find a ton of them : Here



1 Like

thanks a lot…but i am familiar with its 2nd approach(mathematical approach).I tried memoization for very first time in this question so if you can point out what’s fishy than it would be best.

Well, there is no base case in your code(flooring function).So I corrected it by including base case. Here is your corrcected code :

how can i forget that…thanks a lot :slight_smile: :slight_smile: :slight_smile: