I have trying to solve a lot of DP problem but I feel stuck. I can solve most of greedy problem. Any advice
# | User | Rating |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 162 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 154 |
8 | pajenegod | 147 |
9 | BledDest | 145 |
9 | Um_nik | 145 |
I have trying to solve a lot of DP problem but I feel stuck. I can solve most of greedy problem. Any advice
Name |
---|
If you are beginner in DP , I would suggest you practice Recursive DP first. Almost all DP problems you see until 1700-1800 rating can be easily solved with recursive version.
Still if you want to learn iterative, I think writing the transitions on paper helps a lot.
For example, Suppose recursive version is,
inside func(i,j):
DP[i][j] = func(i+1,j+1) + func(i+2,j+1);
I generally convert that right most term into i... like
DP[i-2][j-1] = func(i-1,j) + func(i,j);
=> DP[i-2][j-1] = DP[i-1][j] + DP[i][j]
=> DP[i][j] = DP[i-2][j-1] -DP[i-1][j]
Now I have a formula to use iterative dp using for loop.
PS:This is just personal opinion. There may be better way to figure out transitions. But I learnt it this way. :P
thank you so much for replying. really appreciate. I will try them in recursion.Before I was only trying iterative.
Add Ashishgup to your friendlist and refer his solutions for problems you are trying to solve. He almost always solves using recursive and you can see his solutions to learn.