Dynamic Programming

Go to Problems

Applications

Before diving into DP, let us first understand where do we use DP.

The core concept of DP is to avoid repeated work by remembering partial results (results of subproblems). This is very critical in terms of boosting performance and speed of algorithm. Most of the problems in computer science and real world can be solved using DP technique.

  • In real life scenarios, consider the example where I have to go from home to work everyday. For the first time, I can calculate the shortest path between home and work by considering all possible routes. But, it is not feasible to do the calculation every day. Hence, I will be memorizing that shortest path and will be following that route everyday. In computer science terms, Google Maps will be using DP algorithm to find the shortest paths between two points.

  • Largest Common Subsequence (LCS) problem - Basis of data comparison problems and to identify plagiarism in the contents.

  • Longest Increasing Subsequence problem - used in DNA Matching between two individuals. Generally, the DNAs are represented as strings and to form a match between DNAs of two individuals, the algorithm needs to find out the longest increasing sub sequence between them. In cases of DNA match, the longest common sub-string (LCS) is also found.

  • Knapsack Problem You have a bag of limited capacity and you decide to go on a challenging trek. Due to the capacity restriction, you can only carry certain items in optimum quantity. How do you select the materials and its quantity in efficient manner so that you don’t miss out on important items? That’s where DP comes into aid. 

  • Apart from the above, DP has found its importance in various fields like Bioinformatics, Operations research, Decision Making, Image Processing, MATLAB, MS Word, MS Excel, Financial Optimisations, Genetics, XML indexing and querying and what not! Read More.

Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.

Dynamic Programming Problems

Greedy or dp
Problem Score Companies Time Status
Tushar's Birthday Bombs 200
80:39
Jump Game Array 225 41:16
Min Jumps Array 300 71:56
Tree dp
Problem Score Companies Time Status
Max edge queries! 200 57:34
Max Sum Path in Binary Tree 400 55:23
Suffix / prefix dp
Derived dp
Problem Score Companies Time Status
Chain of Pairs 200 44:12
Max Sum Without Adjacent Elements 225 58:16
Merge elements 300 64:11
Knapsack
Problem Score Companies Time Status
Flip Array 200
81:31
Tushar's Birthday Party 200 72:55
0-1 Knapsack 200 49:10
Equal Average Partition 350 75:08
Dp
Problem Score Companies Time Status
Potions 200 52:35
Adhoc
Problem Score Companies Time Status
Best Time to Buy and Sell Stocks II 225 40:18
Dp optimized backtrack
Problem Score Companies Time Status
Word Break II 350
IBM
68:51
Multiply dp
Problem Score Companies Time Status
Unique Binary Search Trees II 400 36:29
Count Permutations of BST 400
60:04
Breaking words
Problem Score Companies Time Status
Palindrome Partitioning II 400 62:58
Word Break 400
IBM
68:16
lock
Topic Bonus
Bonus will be unlocked after solving min. 1 problem from each bucket