We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
DP comes from Dynamic Programming, is an algorithm paradigm or a technique to solve complex problems breaking them into small ones. Just like you I still do not have any idea about what it is or how to implemented. If you find any DP course for dummies, please let me know, the ones I've found are a little bit difficult to follow.
You are calculating tn by solving the problem from t1 to tn, and recording the results in order to calculate the one you need.
That's the whole idea of dynamic programming: to solve a complex instance of a problem using the solution to smaller instances.
This problem is so simple that you can't really appreciate the technique. If you want an example of a more "serious" DP algorithm, you might look to a classic like the Wagner–Fischer algorithm to compute the distance between strings. It's simple enough but not trivial.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →
I did it using a simple loop and I don't even know what DP is. Could you please show me what a solution using DP looks like?
DP comes from Dynamic Programming, is an algorithm paradigm or a technique to solve complex problems breaking them into small ones. Just like you I still do not have any idea about what it is or how to implemented. If you find any DP course for dummies, please let me know, the ones I've found are a little bit difficult to follow.
https://www.youtube.com/watch?v=P8Xa2BitN3I Check this video out, it might be helpful if you want to understand the basics of Dynamic programming.
Your solution is a DP solution.
You are calculating tn by solving the problem from t1 to tn, and recording the results in order to calculate the one you need.
That's the whole idea of dynamic programming: to solve a complex instance of a problem using the solution to smaller instances.
This problem is so simple that you can't really appreciate the technique. If you want an example of a more "serious" DP algorithm, you might look to a classic like the Wagner–Fischer algorithm to compute the distance between strings. It's simple enough but not trivial.