Before moving on to approaches to solve a DP problem, let us have a look at the characteristics of a problem upon which we can apply the DP technique.
We can apply DP technique to those problems that exhibit the below 2 characteristics:
We know that a nth Fibonacci number (Fib(n)) is nothing but sum of previous 2 fibonacci numbers, i.e: Fib(n) = Fib(n-1) + Fib(n-2).
From the above equation, we can clearly deduce that a problem of size ‘n’ has been reduced to subproblems of size ‘n-1’ and ‘n-2’.
Hence, we can say that Fibonacci numbers have the optimal substructure property.
Note: It is important for a problem to have BOTH the above specified characteristics in order to be eligible to be solved using DP technique.
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Longest Common Subsequence | 200 |
|
42:05 | |
| Longest Palindromic Subsequence | 200 |
|
41:13 | |
| Edit Distance | 300 |
|
47:01 | |
| Repeating Sub-Sequence | 300 |
|
64:12 | |
| Distinct Subsequences | 325 |
|
65:51 | |
| Scramble String | 500 |
|
73:41 | |
| Regular Expression Match | 500 |
|
80:12 | |
| Regular Expression II | 500 |
|
71:22 | |
| Interleaving Strings | 500 |
|
62:21 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Length of Longest Subsequence | 200 |
|
65:01 | |
| Smallest sequence with given Primes | 200 |
|
67:43 | |
| Largest area of rectangle with permutations | 200 |
|
77:08 | |
| Tiling With Dominoes | 200 |
|
64:38 | |
| Paint House! | 200 |
|
42:06 | |
| Ways to Decode | 225 |
|
70:08 | |
| Stairs | 225 |
|
15:14 | |
| Longest Increasing Subsequence | 300 |
|
30:39 | |
| Intersecting Chords in a Circle | 300 |
|
70:39 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Tushar's Birthday Bombs | 200 |
|
80:56 | |
| Jump Game Array | 225 |
|
41:16 | |
| Min Jumps Array | 300 |
|
71:56 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Longest Arithmetic Progression | 200 |
|
76:03 | |
| N digit numbers with digit sum S | 200 |
|
73:23 | |
| Shortest common superstring | 200 |
|
59:51 | |
| Ways to color a 3xN Board | 200 |
|
65:57 | |
| Kth Manhattan Distance Neighbourhood | 200 |
|
65:01 | |
| Best Time to Buy and Sell Stock atmost B times | 200 |
|
64:24 | |
| Coins in a Line | 300 |
|
64:08 | |
| Evaluate Expression To True | 350 |
|
72:57 | |
| Egg Drop Problem! | 450 |
|
58:04 | |
| Best Time to Buy and Sell Stocks III | 700 |
|
64:56 | |
| Longest valid Parentheses | 700 |
|
62:43 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Max edge queries! | 200 |
|
57:08 | |
| Max Sum Path in Binary Tree | 400 |
|
55:23 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Kingdom War | 200 |
|
61:22 | |
| Maximum Path in Triangle | 200 |
|
33:44 | |
| Maximum Size Square Sub-matrix | 200 |
|
45:16 | |
| Increasing Path in Matrix | 200 |
|
47:37 | |
| Minimum Difference Subsets! | 200 |
|
52:31 | |
| Subset Sum Problem! | 200 |
|
46:02 | |
| Unique Paths in a Grid | 300 |
|
34:08 | |
| Dungeon Princess | 300 |
|
72:26 | |
| Min Sum Path in Matrix | 300 |
|
30:33 | |
| Min Sum Path in Triangle | 300 |
|
43:30 | |
| Max Rectangle in Binary Matrix | 350 |
|
79:30 | |
| Rod Cutting | 350 |
|
77:04 | |
| Queen Attack | 350 |
|
62:47 | |
| Dice Throw | 400 |
|
48:07 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Sub Matrices with sum Zero | 200 |
|
76:12 | |
| Coin Sum Infinite | 225 |
|
65:17 | |
| Max Product Subarray | 300 |
|
65:25 | |
| Best Time to Buy and Sell Stocks I | 300 |
|
28:13 | |
| Arrange II | 350 |
|
74:18 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Chain of Pairs | 200 |
|
44:34 | |
| Max Sum Without Adjacent Elements | 225 |
|
58:16 | |
| Merge elements | 300 |
|
65:17 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Flip Array | 200 |
|
82:11 | |
| Tushar's Birthday Party | 200 |
|
73:19 | |
| 0-1 Knapsack | 200 |
|
49:21 | |
| Equal Average Partition | 350 |
|
76:09 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Potions | 200 |
|
52:25 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Best Time to Buy and Sell Stocks II | 225 |
|
40:18 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Word Break II | 350 |
|
69:19 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Unique Binary Search Trees II | 400 |
|
36:38 | |
| Count Permutations of BST | 400 |
|
59:27 |
| Problem | Score | Companies | Time | Status |
|---|---|---|---|---|
| Palindrome Partitioning II | 400 |
|
63:09 | |
| Word Break | 400 |
|
68:35 |