You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-1Lines changed: 10 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -168,7 +168,15 @@ is known.
168
168
linear array, array of length 1 less than total can be taken and a pattern can be found for dynamic programming to make recursive equations.
169
169
- Sometimes results of two DP solutions can be merged using some algo to find the final result.
170
170
- To breakdown any question to DP (recursive equation), follow the crux of the question and break
171
-
it down into a story and later generalize to form recursive equations
171
+
it down into a story and later generalize to form recursive equations. For eg: in case of finding the longest palindrome subsequence in a given string, we compare the last two elements to see if they match or not, this is something that we also do in a normal palindrome question. Here on
172
+
basis of that we are able to derive to equations if they match we move both pointers to next location, if they dont we move one of them (two cases) and find whichever is maximum. Then
173
+
using these recursive equations we build a tree taking an example in mind. Then we find overlapping problems. To see unique problems we generalize the question for which we made the tree to i and j and rather finding how many values of j can exist for each value of i everytime. By that calculation we find unique solutions and solve the question making a table of that size.
174
+
- See if a DP is becoming a fibonacci series. For eg: in the stairs problem
175
+
total ways to reach the nth step f(n) = f(n-1) + f(n-2)
176
+
i.e from n-1 it can take you 1 step and from n-2 it can take you only 1 step of size 2. Therefore, this is
177
+
nothing but fibonacci series.
178
+
- In some algos involving DP you can start from n and in that case answer to n is dependent on n-1 and so on.
179
+
172
180
173
181
# Topic0: Programming Questions
174
182
@@ -386,6 +394,7 @@ it down into a story and later generalize to form recursive equations
386
394
-[Given a sentence without spaces between words. Break the words in such a way that they are meaningful](/dynamic-programming/question19.c)
0 commit comments