Category Archives: Dynamic Programming

Minimum number of jumps to reach end

Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element).

Dynamic Programming | Set 5 (Edit Distance)

Given two strings str1 and str2 and below operations that can performed on str1. Find minimum number of edits (operations) required to convert ‘str1’ into ‘str2’. Insert Remove Replace All of the above operations are of equal cost. Examples: Input: str1 = “geek”, str2 = “gesek” Output: 1 We can convert str1 into str2 by… Read More »

Dynamic Programming | Set 2 (Optimal Substructure Property)

As we discussed in Set 1, following are the two main properties of a problem that suggest that the given problem can be solved using Dynamic programming: 1) Overlapping Subproblems 2) Optimal Substructure We have already discussed Overlapping Subproblem property in the Set 1. Let us discuss Optimal Substructure property here. 2) Optimal Substructure: A… Read More »