Dynamic Programming or DP Last Updated : 18 Mar, 2025 Comments Improve Suggest changes Like Article Like Report Dynamic Programming is an algorithmic technique with the following properties.It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems so that we do not have to re-compute them when needed later. This simple optimization typically reduces time complexities from exponential to polynomial. Some popular problems solved using Dynamic Programming are Fibonacci Numbers, Diff Utility (Longest Common Subsequence), Bellman–Ford Shortest Path, Floyd Warshall, Edit Distance and Matrix Chain Multiplication.Basic of DPIntroduction to DP Tabulation vs MemoizationSteps to solve a DP ProblemBasic ProblemsFibonacci numbersTribonacci NumbersLucas NumbersClimbing StairsClimbing Stairs with 3 MovesWeighted Climbing Stairs Maximum Segments nth Catalan NumberCount Unique BSTsCount Valid ParenthesisWays to Triangulate a PolygonMin Sum in a TriangleMinimum Perfect SquaresWays to Partition a SetBinomial CoefficientPascal's TriangleNth Row of Pascal TriangleMin Sum in a TriangleEasy Problems House RobberMin Cost PathDecode WaysSubset Sum ProblemCoin change problem - Count Ways Coin Change – Minimum Coins to Make SumPainting Fence AlgorithmCutting a RodJump GameLongest Common SubstringCount all paths in a GridPaths in a Grid with ObstaclesPermutations with K Inversions Max A's using Special KeyboardMedium Problems Water Overflow Longest Common Subsequence Longest Increasing SubsequenceEdit DistanceLargest Divisible SubsetWeighted Job Schedulling0-1 Knapsack ProblemPrinting Items in 0/1 KnapsackUnbounded KnapsackWord Break ProblemTile Stacking ProblemBox-Stacking ProblemPartition ProblemLongest Palindromic SubsequenceLongest Common Increasing Subsequence (LCS + LIS)All distinct subset (or subsequence) sumsCount DerangementsMinimum insertions for palindromeWildcard Pattern MatchingRegular Expression MatchingArrange Balls with adjacent of different typesLongest Subsequence with 1 adjacent differenceMaximum size square sub-matrix with all 1sBellman–Ford AlgorithmFloyd Warshall Algorithm Maximum Tip CalculatorHard Problems Largest X Bordered SquareEgg Dropping ProblemPalindrome PartitioningPalindromic Substring CountWord Wrap ProblemOptimal Strategy for a GameThe painter’s partition problemProgram for Bridge and Torch problemMatrix Chain MultiplicationPrinting Matrix Chain MultiplicationMaximum sum rectangleStock Buy and Sell - At-Most k TimesStock Buy and Sell - At Most 2 TimesMin cost to sort strings using ReversalsCount of AP SubsequencesDP on TreesMax Height of Tree when any Node can be RootLongest repeating and non-overlapping substringPalindrome Substrings CountDP Problems Sorted by Topic / Dimensions / Standard ProblemsDP Standard Problems and Variations.DP Problems Dimension Wise (1D, 2D and 3D)DP Problems Topic WiseAdvanced Concepts in Dynamic Programming (DP)Bitmasking and Dynamic Programming | Set 1Bitmasking and Dynamic Programming | Set-2 (TSP)Digit DP | IntroductionSum over Subsets | Dynamic ProgrammingQuick Links:Learn Data Structure and Algorithms | DSA TutorialTop 20 Dynamic Programming Interview Questions‘Practice Problems’ on Dynamic Programming‘Quiz’ on Dynamic Programming Comment More infoAdvertise with us Next Article Dynamic Programming or DP H harendrakumar123 Follow Improve Article Tags : Algorithms Dynamic Programming DSA Practice Tags : AlgorithmsDynamic Programming Similar Reads DSA Tutorial - Learn Data Structures and Algorithms DSA (Data Structures and Algorithms) is the study of organizing data efficiently using data structures like arrays, stacks, and trees, paired with step-by-step procedures (or algorithms) to solve problems effectively. Data structures manage how data is stored and accessed, while algorithms focus on 7 min read Array Data Structure Guide In this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous 4 min read String in Data Structure A string is a sequence of characters. The following facts make string an interesting data structure.Small set of elements. Unlike normal array, strings typically have smaller set of items. For example, lowercase English alphabet has only 26 characters. ASCII has only 256 characters.Strings are immut 3 min read Matrix Data Structure Matrix Data Structure is a two-dimensional array arranged in rows and columns. It is commonly used to represent mathematical matrices and is fundamental in various fields like mathematics, computer graphics, and data processing. Matrices allow for efficient storage and manipulation of data in a stru 2 min read Searching Algorithms Searching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input 3 min read Sorting Algorithms A Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for differ 3 min read Hashing in Data Structure Hashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The 3 min read Two Pointers Technique Two pointers is really an easy and effective technique that is typically used for Two Sum in Sorted Arrays, Closest Two Sum, Three Sum, Four Sum, Trapping Rain Water and many other popular interview questions. Given a sorted array arr (sorted in ascending order) and a target, find if there exists an 11 min read Sliding Window Technique Sliding Window Technique is a method used to solve problems that involve subarray or substring or window. The main idea is to use the results of previous window to do computations for the next window. This technique is commonly used in algorithms like finding subarrays with a specific sum, finding t 13 min read Prefix Sum Array - Implementation and Applications Given an array arr[] of size n, the task is to find the prefix sum of the array. A prefix sum array is another array prefixSum[] of the same size, such that prefixSum[i] is arr[0] + arr[1] + arr[2] . . . arr[i].Examples: Input: arr[] = [10, 20, 10, 5, 15]Output: 10 30 40 45 60Explanation: For each i 8 min read Like