Linear Dynamic Programming Explained
Overview
Linear dynamic programming is one of the most fundamental types of DP problems. Instead of a lengthy introduction, the key is to solve many problems to develop intuition.
Basic Steps
State Definition: Define dp[i] as the optimal solution (maximum, minimum, count of ways, etc.) for the first i elements.
State Transition: Derive the cur ...
Posted on Sat, 27 Jun 2026 17:18:58 +0000 by omfgthezerg
Dynamic Programming Solutions for Subsequence Problems: Longest Increasing Subsequence, Longest Continuous Increasing Subsequence, and Longest Common Subarray
Longest Increasing Subsequence (LIS)
Problem: Given an unsorted array, find the length of the longest increasing subsequence.
Dynamic Programming Approach:
Define DP array: Let lis[i] represent the length of the longest increasing subsequence ending at index i.
Transition: For each i, iterate through all j < i, and if nums[i] > nums[j], ...
Posted on Sun, 21 Jun 2026 16:25:59 +0000 by cryp7
Greedy Algorithm Applications: Common Problem Solutions
Longest Encreasing Subsequence
The problem can be solved using a greedy approach by maintaining a sequence that represents the smallest possible tail value for all increasing subsequences of each length.
The key insight is that for any increasing subsequence, if we encounter a number that's smaller than the current tail of our sequence, we can ...
Posted on Sat, 16 May 2026 11:27:09 +0000 by mrherman