Dynamic Programming Pattern

Define states and transitions; memoize or tabulate.

#Title
10Regular Expression Matching
53Maximum Subarray
62Unique Paths
63Unique Paths II
64Minimum Path Sum
70Climbing Stairs
72Edit Distance
84Largest Rectangle in Histogram
87Scramble String
91Decode Ways
96Unique Binary Search Trees
97Interleaving String
115Distinct Subsequences
120Triangle
123Best Time to Buy and Sell Stock III
132Palindrome Partitioning II
139Word Break
152Maximum Product Subarray
174Dungeon Game
198House Robber
213House Robber II
221Maximal Square
256Paint House
265Paint House II
276Paint Fence
279Perfect Squares
294Flip Game II
300Longest Increasing Subsequence
303Range Sum Query - Immutable
304Range Sum Query 2D - Immutable
309Best Time to Buy and Sell Stock with Cooldown
312Burst Balloons
321Create Maximum Number
322Coin Change
343Integer Break
361Bomb Enemy
368Largest Divisible Subset
375Guess Number Higher or Lower II
377Combination Sum IV
403Frog Jump
416Partition Equal Subset Sum
418Sentence Screen Fitting
446Arithmetic Slices II - Subsequence
465Optimal Account Balancing
466Count The Repetitions
467Unique Substrings in Wraparound String
471Encode String with Shortest Length
472Concatenated Words
474Ones and Zeroes
486Predict the Winner
494Target Sum
509Fibonacci Number
514Freedom Trail
516Longest Palindromic Subsequence
518Coin Change 2
54201 Matrix
546Remove Boxes
552Student Attendance Record II
562Longest Line of Consecutive One in Matrix
568Maximum Vacation Days
576Out of Boundary Paths
583Delete Operation for Two Strings
600Non-negative Integers without Consecutive Ones
629K Inverse Pairs Array
639Decode Ways II
6502 Keys Keyboard
6514 Keys Keyboard
656Coin Path
664Strange Printer
673Number of Longest Increasing Subsequence
688Knight Probability in Chessboard
689Maximum Sum of 3 Non-Overlapping Subarrays
698Partition to K Equal Sum Subsets
712Minimum ASCII Delete Sum for Two Strings
714Best Time to Buy and Sell Stock with Transaction Fee
718Maximum Length of Repeated Subarray
727Minimum Window Subsequence
730Count Different Palindromic Subsequences
740Delete and Earn
741Cherry Pickup
746Min Cost Climbing Stairs
750Number Of Corner Rectangles
764Largest Plus Sign
788Rotated Digits
790Domino and Tromino Tiling
799Champagne Tower
801Minimum Swaps To Make Sequences Increasing
805Split Array With Same Average
808Soup Servings
813Largest Sum of Averages
818Race Car
823Binary Trees With Factors
837New 21 Game
838Push Dominoes
877Stone Game
879Profitable Schemes
903Valid Permutations for DI Sequence
920Number of Music Playlists
926Flip String to Monotone Increasing
931Minimum Falling Path Sum
935Knight Dialer
940Distinct Subsequences II
943Find the Shortest Superstring
956Tallest Billboard
960Delete Columns to Make Sorted III
964Least Operators to Express Number
980Unique Paths III
983Minimum Cost For Tickets
1000Minimum Cost to Merge Stones
1025Divisor Game
1027Longest Arithmetic Sequence
1035Uncrossed Lines
1039Minimum Score Triangulation of Polygon
1043Partition Array for Maximum Sum
1048Longest String Chain
1049Last Stone Weight II
1066Campus Bikes II
1092Shortest Common Supersequence
1105Filling Bookcase Shelves
1125Smallest Sufficient Team
1137N-th Tribonacci Number
1139Largest 1-Bordered Square
1140Stone Game II
1143Longest Common Subsequence
1155Number of Dice Rolls With Target Sum
1182Shortest Distance to Target Color
1186Maximum Subarray Sum with One Deletion
1187Make Array Strictly Increasing
1191K-Concatenation Maximum Sum
1197Minimum Knight Moves
1216Valid Palindrome III
1218Longest Arithmetic Subsequence of Given Difference
1220Count Vowels Permutation
1223Dice Roll Simulation
1230Toss Strange Coins
1235Maximum Profit in Job Scheduling
1239Maximum Length of a Concatenated String with Unique Characters
1246Palindrome Removal
1259Handshakes That Don't Cross
1262Greatest Sum Divisible by Three
1269Number of Ways to Stay in the Same Place After Some Steps
1273Delete Tree Nodes
1277Count Square Submatrices with All Ones
1278Palindrome Partitioning III
1289Minimum Falling Path Sum II
1301Number of Paths with Max Score
1312Minimum Insertion Steps to Make a String Palindrome
1314Matrix Block Sum
1320Minimum Distance to Type a Word Using Two Fingers
1335Minimum Difficulty of a Job Schedule
1387Sort Integers by The Power Value
1388Pizza With 3n Slices
1395Count Number of Teams
1406Stone Game III
1411Number of Ways to Paint N × 3 Grid
1416Restore The Array
1420Build Array Where You Can Find The Maximum Exactly K Comparisons
1434Number of Ways to Wear Different Hats to Each Other
1444Number of Ways of Cutting a Pizza
1449Form Largest Integer With Digits That Add up to Target
1458Max Dot Product of Two Subsequences
1463Cherry Pickup II
1467Probability of a Two Boxes Having The Same Number of Distinct Balls
1473Paint House III
1477Find Two Non-overlapping Sub-arrays Each With Target Sum
1478Allocate Mailboxes
1483Kth Ancestor of a Tree Node
1494Parallel Courses II
1510Stone Game IV
1521Find a Value of a Mysterious Function Closest to Target
1524Number of Sub-arrays With Odd Sum
1531String Compression II
1547Minimum Cost to Cut a Stick
1548The Most Similar Path in a Graph
1553Minimum Number of Days to Eat N Oranges
1563Stone Game V
1575Count All Possible Routes
1594Maximum Non Negative Product in a Matrix
1595Minimum Cost to Connect Two Groups of Points
1626Best Team With No Conflicts
1639Number of Ways to Form a Target String Given a Dictionary
1655Distribute Repeating Integers
1671Minimum Number of Removals to Make Mountain Array
1682Longest Palindromic Subsequence II
1690Stone Game VII
1691Maximum Height by Stacking Cuboids
1692Count Ways to Distribute Candies
1745Palindrome Partitioning IV
1746Maximum Subarray Sum After One Operation
1770Maximum Score from Performing Multiplication Operations
1771Maximize Palindrome Length From Subsequences
1774Closest Dessert Cost
1787Make the XOR of All Segments Equal to Zero
1799Maximize Score After N Operations
1803Count Pairs With XOR in a Range
1815Maximum Number of Groups Getting Fresh Donuts
1824Minimum Sideway Jumps
1857Largest Color Value in a Directed Graph
1866Number of Ways to Rearrange Sticks With K Sticks Visible
1871Jump Game VII
1872Stone Game VIII
1879Minimum XOR Sum of Two Arrays
1883Minimum Skips to Arrive at Meeting On Time
1884Egg Drop With 2 Eggs and N Floors
1896Minimum Cost to Change the Final Value of Expression
1900The Earliest and Latest Rounds Where Players Compete
1908Game of Nim
1931Painting a Grid With Three Different Colors
1947Maximum Compatibility Score Sum
1955Count Number of Special Subsequences
1959Minimum Total Space Wasted With K Resizing Operations
1960Maximum Product of the Length of Two Palindromic Substrings
1964Find the Longest Valid Obstacle Course at Each Position
1977Number of Ways to Separate Numbers
1981Minimize the Difference Between Target and Chosen Elements
1982Find Array Given Subset Sums
1986Minimum Number of Work Sessions to Finish the Tasks
1987Number of Unique Good Subsequences
1994The Number of Good Subsets
1997First Day Where You Have Been in All the Rooms
2002Maximum Product of the Length of Two Palindromic Subsequences
2008Maximum Earnings From Taxi
2019The Score of Students Solving Math Expression
2031Count Subarrays With More Ones Than Zeros
2044Count Number of Maximum Bitwise-OR Subsets
2052Minimum Cost to Separate Sentence Into Rows
2060Check if an Original String Exists Given Two Encoded Strings
2088Count Fertile Pyramids in a Land
2140Solving Questions With Brainpower
2143Choose Numbers From Two Arrays in Range
2167Minimum Time to Remove All Cars Containing Illegal Goods
2172Maximum AND Sum of Array
2174Remove All Ones With Row and Column Flips II
2184Number of Ways to Build Sturdy Brick Wall
2188Minimum Time to Finish the Race
2189Number of Ways to Build House of Cards
2209Minimum White Tiles After Covering With Carpets
2218Maximum Value of K Coins From Piles
2222Number of Ways to Select Buildings
2247Maximum Cost of Trip With K Highways
2263Make Array Non-decreasing or Non-increasing
2266Count Number of Texts
2267Check if There Is a Valid Parentheses String Path
2289Steps to Make Array Non-decreasing
2291Maximum Profit From Trading Stocks
2297Jump Game VIII
2304Minimum Path Cost in a Grid
2305Fair Distribution of Cookies
2312Selling Pieces of Wood
2318Number of Distinct Roll Sequences
2320Count Number of Ways to Place Houses
2327Number of People Aware of a Secret
2328Number of Increasing Paths in a Grid
2338Count the Number of Ideal Arrays
2361Minimum Costs Using the Train Line
2369Check if There is a Valid Partition For The Array
2370Longest Ideal Subsequence
2380Time Needed to Rearrange a Binary String
2403Minimum Time to Kill All Monsters
2430Maximum Deletions on a String
2431Maximize Total Tastiness of Purchased Fruits
2435Paths in Matrix Whose Sum Is Divisible by K
2447Number of Subarrays With GCD Equal to K
2463Minimum Total Distance Traveled
2464Minimum Subarrays in a Valid Split
2466Count Ways To Build Good Strings
2470Number of Subarrays With LCM Equal to K
2475Number of Unequal Triplets in Array
2478Number of Beautiful Partitions
2484Count Palindromic Subsequences
2495Number of Subarrays Having Even Product
2501Longest Square Streak in an Array
2510Check if There is a Path With Equal Number of 0's And 1's
2518Number of Great Partitions
2533Number of Good Binary Strings
2547Minimum Cost to Split an Array
2552Count Increasing Quadruplets
2555Maximize Win From Two Segments
2556Disconnect Path in a Binary Matrix by at Most One Flip
2565Subsequence With the Minimum Score
2572Count the Number of Square-Free Subsets
2573Find the String with LCP
2585Number of Ways to Earn Points
2597The Number of Beautiful Subsets
2638Count the Number of K-Free Subsets
2648Generate Fibonacci Sequence
2681Power of Heroes
2684Maximum Number of Moves in a Grid
2707Extra Characters in a String
2713Maximum Strictly Increasing Cells in a Matrix
2719Count of Integers
2742Painting the Walls
2746Decremental String Concatenation
2767Partition String Into Minimum Beautiful Substrings
2770Maximum Number of Jumps to Reach the Last Index
2771Longest Non-decreasing Subarray From Two Arrays
2786Visit Array Positions to Maximize Score
2787Ways to Express an Integer as Sum of Powers
2801Count Stepping Numbers in Range
2809Minimum Time to Make Array Sum At Most x
2826Sorting Three Groups
2827Number of Beautiful Integers in the Range
2830Maximize the Profit as the Salesman
2851String Transformation
2896Apply Operations to Make Two Strings Equal
2901Longest Unequal Adjacent Groups Subsequence II
2902Count of Sub-Multisets With Bounded Sum
2911Minimum Changes to Make K Semi-palindromes
2912Number of Ways to Reach Destination in the Grid
2913Subarrays Distinct Element Sum of Squares I
2915Length of the Longest Subsequence That Sums to Target
2916Subarrays Distinct Element Sum of Squares II
2919Minimum Increment Operations to Make Array Beautiful
2930Number of Strings Which Can Be Rearranged to Contain Substring
2932Maximum Strong Pair XOR I
2935Maximum Strong Pair XOR II
2941Maximum GCD-Sum of a Subarray
2944Minimum Number of Coins for Fruits
2945Find Maximum Non-decreasing Array Length
2969Minimum Number of Coins for Fruits II
2976Minimum Cost to Convert String I
2977Minimum Cost to Convert String II
2979Most Expensive Item That Can Not Be Bought
2992Number of Self-Divisible Permutations
3018Maximum Number of Removal Queries That Can Be Processed I
3020Find the Maximum Number of Elements in Subset
3040Maximum Number of Operations With the Same Score II
3041Maximize Consecutive Elements in an Array After Modification
3077Maximum Strength of K Disjoint Subarrays
3082Find the Sum of the Power of All Subsequences
3098Find the Sum of Subsequence Powers
3101Count Alternating Subarrays
3117Minimum Sum of Values by Dividing Array
3122Minimum Number of Operations to Satisfy Conditions
3129Find All Possible Stable Binary Arrays I
3130Find All Possible Stable Binary Arrays II
3135Equalize Strings by Adding or Removing Characters at Ends
3144Minimum Substring Partition of Equal Character Frequency
3148Maximum Difference Score in a Grid
3149Find the Minimum Cost Array Permutation
3171Find Subarray With Bitwise OR Closest to K
3176Find the Maximum Length of a Good Subsequence I
3177Find the Maximum Length of a Good Subsequence II
3180Maximum Total Reward Using Operations I
3181Maximum Total Reward Using Operations II
3183The Number of Ways to Make the Sum
3186Maximum Total Damage With Spell Casting
3196Maximize Total Cost of Alternating Subarrays
3197Find the Minimum Area to Cover All Ones II
3201Find the Maximum Length of Valid Subsequence I
3202Find the Maximum Length of Valid Subsequence II
3205Maximum Array Hopping Score I
3209Number of Subarrays With AND Value of K
3212Count Submatrices With Equal Frequency of X and Y
3213Construct String with Minimum Cost
3225Maximum Score From Grid Operations
3247Number of Subsequences with Odd Sum
3250Find the Count of Monotonic Pairs I
3251Find the Count of Monotonic Pairs II
3253Construct String with Minimum Cost (Easy)
3259Maximum Energy Boost From Two Drinks
3269Constructing Two Increasing Arrays
3276Select Cells in Grid With Maximum Score
3277Maximum XOR Score Subarray Queries
3283Maximum Number of Moves to Kill All Pawns
3287Find the Maximum Sequence Value of Array
3290Maximum Multiplication Score
3291Minimum Number of Valid Strings to Form Target I
3292Minimum Number of Valid Strings to Form Target II
3299Sum of Consecutive Subsequences
3316Find Maximum Removals From Source String
3317Find the Number of Possible Ways for an Event
3320Count The Number of Winning Sequences
3332Maximum Points Tourist Can Earn
3333Find the Original Typed String II
3335Total Characters in String After Transformations I
3336Find the Number of Subsequences With Equal GCD
3337Total Characters in String After Transformations II
3339Find the Number of K-Even Arrays
3343Count Number of Balanced Permutations
3351Sum of Good Subsequences
3352Count K-Reducible Numbers Less Than N
3359Find Sorted Submatrices With Maximum Element at Most K
3363Find the Maximum Number of Fruits Collected
3366Minimum Array Sum
3376Minimum Time to Break Locks I
3381Maximum Subarray Sum With Length Divisible by K
3388Count Beautiful Splits in an Array
3389Minimum Operations to Make Character Frequencies Equal
3393Count Paths With the Given XOR Value
3409Longest Subsequence With Decreasing Adjacent Difference
3414Maximum Score of Non-overlapping Intervals
3418Maximum Amount of Money Robot Can Earn
3429Paint House IV
3434Maximum Frequency After Subarray Operation
3441Minimum Cost Good Caption
3444Minimum Increments for Target Multiples in an Array
3448Count Substrings Divisible By Last Digit
3459Length of Longest V-Shaped Diagonal Segment
3466Maximum Coin Collection
3469Find Minimum Cost to Remove Array Elements
3472Longest Palindromic Subsequence After at Most K Operations
3473Sum of K Subarrays With Length at Least M
3489Zero Array Transformation IV
3490Count Beautiful Numbers
3500Minimum Cost to Divide Array Into Subarrays
3503Longest Palindrome After Substring Concatenation I
3504Longest Palindrome After Substring Concatenation II
3505Minimum Operations to Make Elements Within K Subarrays Equal
3509Maximum Product of Subsequences With an Alternating Sum Equal to K
3524Find X Value of Array I
3525Find X Value of Array II
3530Maximum Profit from Valid Topological Order in DAG
3533Concatenated Divisibility
3538Merge Operations for Minimum Travel Time
3539Find Sum of Array Product of Magical Sequences
3543Maximum Weighted K-Edge Path
3563Lexicographically Smallest String After Adjacent Removals
3573Best Time to Buy and Sell Stock V
3574Maximize Subarray GCD Score
3578Count Partitions With Max-Min Difference at Most K
3579Minimum Steps to Convert String with Operations
3583Count Special Triplets
3592Inverse Coin Change
3595Once Twice
3599Partition Array to Minimize XOR
3603Minimum Cost Path with Alternating Directions II
3610Minimum Number of Primes to Sum to Target
3615Longest Palindromic Path in Graph
3620Network Recovery Pathways
3628Maximum Number of Subsequences After One Inserting
3647Maximum Weight in Two Bags
3651Minimum Cost Path with Teleportations
3654Minimum Sum After Divisible Sum Deletions
3661Maximum Walls Destroyed by Robots
3665Twisted Mirror Path Count
3670Maximum Product of Two Integers With No Common Bits
3685Subsequence Sum After Capping Elements
3686Number of Stable Subsequences
3693Climbing Stairs II
3699Number of ZigZag Arrays I
3704Count No-Zero Pairs That Sum to N
3717Minimum Operations to Make the Array Beautiful
3725Count Ways to Choose Coprime Integers from Rows
3742Maximum Path Score in a Grid
3743Maximize Cyclic Partition Score
3753Total Waviness of Numbers in Range II
3757Number of Effective Subsequences
3791Number of Balanced Integers in a Range
3796Find Maximum Value in a Constrained Sequence
3797Count Routes to Climb a Rectangular Grid
3801Minimum Cost to Merge Sorted Lists
3811Number of Alternating XOR Partitions
3821Find Nth Smallest Integer With K One Bits
3826Minimum Partition Score
3830Longest Alternating Subarray After Removing At Most One Element
3836Maximum Score Using Exactly K Pairs
3840House Robber V
3850Count Sequences to K
3864Minimum Cost to Partition a Binary String
3869Count Fancy Numbers in a Range
3877Minimum Removals to Achieve Target XOR
3882Minimum XOR Path in a Grid
3883Count Non Decreasing Arrays With Given Digit Sums
3891Minimum Increase to Maximize Special Indices
3906Count Good Integers on a Grid Path
3916Number of ZigZag Arrays III
3929Minimum Partition Score II
3946Maximum Number of Items From Sale I
3952Maximum Total Value of Covered Indices
3953Maximum Score with Co-Prime Element
3956Maximum Sum of M Non-Overlapping Subarrays I
3957Maximum Sum of M Non-Overlapping Subarrays II
3962Maximum Subarray Sum After at Most K Swaps
3966Count Good Integers in a Range
3976Maximum Subarray Sum After Multiplier
3981Count Distinct Ways to Form Target from Two Strings
3983Subsequence After One Replacement
3989Maximum Consistent Columns in a Grid