Leetcode 70. Climbing Stairs

Now that we know 3rd step can be reached directly from 1st and 2nd, what will be the number of ways in which we can reach the step 3? It would be all the ways in which we can reach the step 1 (because we can always take 2 steps from here to reach the step 3) + the number of ways in which we can reach the step 2 (because we can always take 1 more step to reach the step 3). … More Leetcode 70. Climbing Stairs

Dynamic Programming

The idea behind solving dynamic programming problems is simple – remember what you have already solved and use the already computed solution in case you are solving the same problem again. In other words, solve one problem only once and remember the solution to it so that you can quickly provide the solution without the need to solve the problem again. … More Dynamic Programming