Dynamic Programming

Dynamic Programming

Master Dynamic Programming with 50+ problems from basic to advanced level

41 Problems
Intermediate
Watch Playlist

All Problems

41 problems
1
0/1 Knapsack Recursive
Maximize total value of items in knapsack with capacity W. Items are either completely included or excluded (0/1 property). Solve using simple recursion.
Medium
Not Attempted
Video
2
0/1 Knapsack Memoization
Use recursion with memoization (top-down DP) to solve 0/1 Knapsack efficiently by avoiding repeated work of overlapping subproblems.
Medium
Not Attempted
Video
3
0/1 Knapsack Bottom-up DP
Solve 0/1 Knapsack using bottom-up dynamic programming with tabulation, filling dp array iteratively.
Medium
Not Attempted
Video
4
Subset Sum Problem
Determine if there exists a subset of given set with sum equal to given sum.
Medium
Not Attempted
Video
5
Equal Sum Partition Problem
Check if given set can be partitioned into two subsets such that sums of both subsets are equal.
Medium
Not Attempted
Video
6
Count of Subsets with a Given Sum
Count number of subsets in a set which sum to a given sum.
Medium
Not Attempted
Video
7
Minimum Subset Sum Difference
Split set into two subsets such that difference of their sums is minimized.
Medium
Not Attempted
Video
8
Count of Subsets with Given Difference
Count the number of subset pairs whose difference of sums equals the given value.
Medium
Not Attempted
Video
9
Target Sum
Assign + or - signs to array elements such that the expression sums to target value. Count number of such ways.
Medium
Not Attempted
Video
10
Unbounded Knapsack
Given weights and values of n items, and a knapsack capacity W, find the maximum value of items that can be put in the knapsack if an unlimited number of instances of each item can be used.
Medium
Not Attempted
Video
11
Rod Cutting Problem
Given a rod of length n and prices for different lengths, determine the maximum revenue obtainable by cutting up the rod and selling the pieces. Unlimited pieces allowed.
Medium
Not Attempted
Video
12
Coin Change - I: Maximum Number of Ways
Find the number of ways to make change for amount W using given coin denominations of infinite supply.
Medium
Not Attempted
Video
13
Longest Common Subsequence Recursive
Given two sequences, find the length of their longest subsequence present in both of them using a recursive approach.
Medium
Not Attempted
Video
14
Longest Common Subsequence Memoization
Use top-down dynamic programming (memoization) to efficiently find the length of longest common subsequence between two sequences.
Medium
Not Attempted
Video
15
Longest Common Subsequence Bottom-Up (DP)
Find length of longest common subsequence of two strings using iterative bottom-up dynamic programming.
Medium
Not Attempted
Video
16
Longest Common Substring
Given two strings, find the length of the longest substring that is common to both.
Medium
Not Attempted
Video
17
Print Longest Common Subsequence
Given two strings, print their longest common subsequence. If there are multiple, any one is acceptable.
Medium
Not Attempted
Video
18
Shortest Common Supersequence
Find the length of the shortest string that has both given strings as subsequences.
Medium
Not Attempted
Video
19
Minimum Insertions and Deletions
Find the minimum number of insertions and deletions to convert string 'a' to string 'b'.
Medium
Not Attempted
Video
20
Longest Palindromic Subsequence
Find the length of the longest subsequence of a given string that is also a palindrome.
Medium
Not Attempted
Video
21
Minimum Deletions to Make a Palindrome
Find the minimum number of characters to delete from a string to make it a palindrome.
Medium
Not Attempted
Video
22
Print Shortest Common Supersequence
Given two strings, print their shortest common supersequence.
Hard
Not Attempted
Video
23
Longest Repeating Subsequence
Find the length of the longest subsequence that appears at least twice in the given string, where the two occurrences have different indices.
Medium
Not Attempted
Video
24
Sequence Pattern Matching
Check if a string 'a' is a subsequence of another string 'b'.
Easy
Not Attempted
Video
25
Matrix Chain Multiplication Recursive
Given a sequence of matrix dimensions, determine the minimum number of scalar multiplications needed to multiply the entire chain using simple recursion.
Medium
Not Attempted
Video
26
Matrix Chain Multiplication Memoization
Optimize the recursive MCM solution using top-down memoization to avoid redundant calculations.
Medium
Not Attempted
Video
27
Palindrome Partitioning Recursive
Given a string, find the minimum number of cuts required to partition it into palindromic substrings using recursion.
Hard
Not Attempted
Video
28
Palindrome Partitioning Memoization
Use memoization to optimize the palindrome partitioning recursive solution.
Hard
Not Attempted
Video
29
Palindrome Partitioning Optimization
Compute minimum cuts for palindrome partitioning in O(n^2) time using precomputed palindrome table.
Hard
Not Attempted
Video
30
Evaluate Expression to True Recursive
Count ways to parenthesize a boolean expression of T,F and operators &|^ so it evaluates to true, using recursion.
Hard
Not Attempted
Video
31
Evaluate Expression to True (Memoization with Map)
Optimize the recursive solution for expression evaluation by using a map to memoize subproblem results.
Hard
Not Attempted
Video
32
Evaluate Expression to True (Memoization with 3D Array)
Use a 3D array dp[i][j][t] to memoize the count of ways for substring s[i..j] to evaluate to t (0/1).
Hard
Not Attempted
Video
33
Scramble String Recursive
Determine if one string is a scrambled form of another by recursive partition and swap.
Hard
Not Attempted
Video
34
Scramble String Memoization
Optimize the scramble string recursive solution by memoizing results for pairs of strings.
Hard
Not Attempted
Video
35
Egg Dropping Problem Recursive
Find the minimum number of attempts needed in the worst case to determine the highest floor from which an egg can be dropped without breaking, using a purely recursive approach.
Hard
Not Attempted
Video
36
Egg Dropping Problem Memoization
Use top-down memoization to optimize the recursive egg dropping solution, caching results for subproblems (E, F).
Hard
Not Attempted
Video
37
Egg Dropping Problem Memoization Optimization
Optimize the memoized egg dropping solution by early stopping when minimum possible is reached.
Hard
Not Attempted
Video
38
Egg Dropping Problem Binary Search Optimization
Optimize the DP egg dropping solution by using binary search on the floor index to minimize attempts.
Hard
Not Attempted
Video
39
Diameter of a Binary Tree
Find the length of the longest path between any two nodes in a binary tree. This path may or may not pass through the root.
Medium
Not Attempted
Video
40
Maximum Path Sum from Any Node to Any Node
Find the maximum path sum in a binary tree where the path can start and end at any node.
Hard
Not Attempted
Video
41
Maximum Path Sum from Leaf to Leaf
Find the maximum sum path between any two leaf nodes in a binary tree.
Hard
Not Attempted
Video