📄️ What is Dynamic Programming?
To see this article on my blog, click here!
📄️ Example: Electric Car⚡
Let's try a bit of a harder question than the Fibonacci example.
📄️ Two Dimensional Dynamic Programming
Sometimes, when you're solving subproblems that are a bit more complex, you'll need more than just a single array to store the results of your subproblems. This is where Two-dimensional dynamic programming comes in, where intermediate results of subproblems are stored in a table (or 2D array).
📄️ 2-DP Example: Coins🪙
You are given coins with values D\1, D\2,..., D\_n, as well as a target price, P. Create an algorithm that returns the smallest number of coins you can use from the list to make exactly P cents, or return infinity if it is not possible. You can use each coin at most once.