Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Descriptions to Classic DP Problems #1269

Merged
merged 6 commits into from
Jun 9, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/dynamic_programming/intro-to-dp.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,21 @@ That's it. That's the basics of dynamic programming: Don't repeat work you've do
One of the tricks to getting better at dynamic programming is to study some of the classic examples.

## Classic Dynamic Programming Problems
- 0-1 Knapsack
- Subset Sum
- Longest Increasing Subsequence
- Counting all possible paths from top left to bottom right corner of a matrix
- Longest Common Subsequence
- Longest Path in a Directed Acyclic Graph (DAG)
- Coin Change
- Longest Palindromic Subsequence
- Rod Cutting
- Edit Distance
- Bitmask Dynamic Programming
- Digit Dynamic Programming
- Dynamic Programming on Trees
| Name | Description | Example Poblems |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 0-1 Knapsack | 0-1 Knapsack | given a set of items, each with a weight and a value, and a knapsack with a maximum capacity. | [D - Knapsack 1 (](https://atcoder.jp/contests/dp/tasks/dp_d)[atcoder.jp](http://atcoder.jp)[)](https://atcoder.jp/contests/dp/tasks/dp_d) |
Zyad-Ayad marked this conversation as resolved.
Show resolved Hide resolved
| Subset Sum | you are given a set of integers and a target sum. The task is to determine whether there exists a subset of the given set whose elements sum up to the target sum. | |
Zyad-Ayad marked this conversation as resolved.
Show resolved Hide resolved
| Longest Increasing Subsequence | It's a problem that asks for the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order. | [Longest Increasing Subsequence - LeetCode](https://leetcode.com/problems/longest-increasing-subsequence/description/) |
| Counting all possible paths in a matrix. | Solved using dynamic programming or recursion with memoization. | [Unique Paths - LeetCode](https://leetcode.com/problems/unique-paths/description/) |
| Longest Common Subsequence | Given two sequences (usually strings), the task is to find the length of the longest subsequence that is common to both sequences. | [F - LCS (](https://atcoder.jp/contests/dp/tasks/dp_f)[atcoder.jp](http://atcoder.jp)[)](https://atcoder.jp/contests/dp/tasks/dp_f) |
| Longest Path in a Directed Acyclic Graph (DAG) | Unlike finding the longest path in a general graph, which is an NP-hard problem, finding the longest path in a DAG can be solved efficiently using dynamic programming. | [G - Longest Path (](https://atcoder.jp/contests/dp/tasks/dp_g)[atcoder.jp](http://atcoder.jp)[)](https://atcoder.jp/contests/dp/tasks/dp_g) |
| Longest Palindromic Subsequence | Finding the Longest Palindromic Subsequence (LPS) of a given string. | [Longest Palindromic Subsequence - LeetCode](https://leetcode.com/problems/longest-palindromic-subsequence/description/) |
| Rod Cutting | It involves finding the maximum revenue that can be obtained by cutting a rod of length n into smaller pieces and selling them. | |
| Edit Distance | It involves finding the minimum number of operations required to transform one string into another, where the allowed operations are insertion, deletion, or substitution of a single character. | [CSES - Edit Distance](https://cses.fi/problemset/task/1639) |
| Bitmask Dynamic Programming | Bitmask Dynamic Programming is a technique used to solve combinatorial optimization problems, where the state can be represented compactly using bitmasks. | [Problem - F - Codeforces](https://codeforces.com/contest/1043/problem/F) |
| Digit Dynamic Programming | Digit Dynamic Programming is a technique used to solve problems related to digits of a number. | [SPOJ.com](http://SPOJ.com) [- Problem PR003004](https://www.spoj.com/problems/PR003004/) |
| Dynamic Programming on Trees | A technique used to solve various problems related to trees, such as finding the longest path, computing subtree properties, or counting certain structures within the tree. | [P - Independent Set (](https://atcoder.jp/contests/dp/tasks/dp_p)[atcoder.jp](http://atcoder.jp)[)](https://atcoder.jp/contests/dp/tasks/dp_p) |
| Range Dynamic Programming | Range Dynamic Programming is a technique used to solve problems where you need to find optimal solutions for subranges within a given range or array. | |

Of course, the most important trick is to practice.

Expand All @@ -151,3 +153,7 @@ Of course, the most important trick is to practice.
* [LeetCode - 118. Pascal's Triangle](https://leetcode.com/problems/pascals-triangle/description/)
* [LeetCode - 1025. Divisor Game](https://leetcode.com/problems/divisor-game/description/)

## Dp Contests
* [Atcoder - Educational DP Contest](https://atcoder.jp/contests/dp/tasks)
* [CSES - Dynamic Programming](https://cses.fi/problemset/list/)