How to approach problems for DP? and as a beginner should I start approaching the question in tabulation method or in recursive method and then change it to the tabulation method ?
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | atcoder_official | 162 |
3 | maomao90 | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
How to approach problems for DP? and as a beginner should I start approaching the question in tabulation method or in recursive method and then change it to the tabulation method ?
Name |
---|
Suggestion: - Don't cheat in any contest. - Challenge yourself with harder problems independently. If you encounter difficulties, start with a brute force approach. If it's inefficient (e.g., Time Limit Exceeded), then consider alternative strategies such as: — Mathematical optimizations — Implementation techniques like greedy algorithms
For instance, when faced with a challenging problem like "Longest Increasing Subsequence (LIS)", you might initially attempt a brute force solution that checks all subsequences. However, this approach can become impractical for larger inputs. To optimize, you could implement a dynamic programming solution that uses memoization or tabulation to efficiently compute the LIS length in ( O(n^2) ) or ( O(n \log n) ) time complexity, respectively.
approach of the LIS problem using dynamic programming:
Understand the Problem: Given an array of integers, find the length of the longest increasing subsequence.
Start with Recursive Approach: Begin by defining a recursive function to explore all subsequences:
Practice and Compare: Solve other dynamic programming problems using both recursive with memoization and iterative tabulation approaches to understand their strengths and when to use each.
Refine Solutions: Continuously review and optimize your solutions for clarity and efficiency based on problem requirements.