A curated collection of **Dynamic Programming (DP)** problems, techniques, and implementations in C++. This repo is aimed at learners who want to strengthen their DP understanding for contests, interviews, and algorithmic challenges.
- Cover classical DP problems and patterns
- Include multiple variants and optimizations (memoization, tabulation, space optimization)
- Provide clear, well-commented C++ code
- Use problem statements and test cases to practice
- Structure content in a logical progression from simple → complex
- Basic DP (Fibonacci, Climbing Stairs, etc.)
- 0/1 Knapsack and Unbounded Knapsack
- Sequence DP: LIS, LCS, Edit Distance, etc.
- Interval DP, Partition DP, Matrix Chain Multiplication
- DP with State Compression (Bitmask)
- Tree DP and Graph + DP Hybrid Techniques
- Optimization Techniques:
- Space optimization
- Rolling arrays
- Transition improvements
- 🟢 Learners who understand basic algorithms and want to dive deeper
- 🎯 Students preparing for coding interviews (product & service companies)
- 🧠 Competitive programmers aiming to master DP patterns for contests
- 📝 Anyone looking for clean, reusable code & well-structured solutions
Contributions and improvements are always welcome! 🙌
You can:
- ✍️ Add new DP problems and their variations
- ⚡ Provide optimized solutions or multiple approaches to existing problems
- 📝 Add detailed comments, edge cases, and test cases
- 🧭 Improve folder structure or add roadmaps / topic-wise checklists
- 🧠 Suggest new problem patterns or techniques to cover
- Fork the repository
- Make your changes in your branch
- Open a Pull Request (PR) describing what you’ve added or changed
Contributions of all levels — from typo fixes to new topics — are welcome!
Dynamic-Programming/
├── 01_Basics_DP/
│ ├── fibonacci_dp.cpp
│ ├── climbing_stairs.cpp
│ └── ...
│
├── 02_Knapsack_Variants/
│ ├── 0_1_knapsack.cpp
│ ├── unbounded_knapsack.cpp
│ └── ...
│
├── 03_DP_on_Sequences/
│ ├── longest_increasing_subsequence.cpp
│ ├── longest_common_subsequence.cpp
│ └── edit_distance.cpp
│
├── 04_DP_on_Intervals_And_Subarrays/
│ ├── matrix_chain_multiplication.cpp
│ ├── partition_dp.cpp
│ └── ...
│
├── 05_DPGraphs_States/
│ ├── bitmask_dp_states.cpp
│ ├── dp_on_trees.cpp
│ └── ...
│
└── README.md