题库chevron_right分类chevron_right动态规划
grid_view

动态规划

529 道题目
简单: 12中等: 249困难: 268

动态规划 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
5

最长回文子串

Find the longest contiguous palindromic substring in a given string using dynamic programming and two-pointer expansion …

中等
10

正则表达式匹配

The Regular Expression Matching problem involves checking if a string matches a pattern using '.' and '*'.

困难
22

括号生成

Generate Parentheses requires generating all valid combinations of parentheses with given pairs using backtracking and s…

中等
32

最长有效括号

Compute the length of the longest well-formed parentheses substring using state transition dynamic programming and stack…

困难
42

接雨水

Calculate the total trapped rain water using the elevation map array, leveraging dynamic programming and two-pointer pat…

困难
44

通配符匹配

Implement full wildcard pattern matching using '?' and '*' by applying state transition dynamic programming with careful…

困难
45

跳跃游戏 II

Jump Game II requires finding the minimum jumps to reach the end of an array using dynamic programming and greedy techni…

中等
53

最大子数组和

Maximum Subarray is a classic state transition dynamic programming problem about deciding whether to extend or restart a…

中等
55

跳跃游戏

Solve the Jump Game problem using state transition dynamic programming to determine if you can reach the last index of t…

中等
62

不同路径

Calculate the number of unique paths for a robot to move on an m x n grid with only right and down movements.

中等
63

不同路径 II

Calculate the number of unique paths from top-left to bottom-right in a grid with obstacles using dynamic programming st…

中等
64

最小路径和

Compute the minimum sum from top-left to bottom-right in a grid using state transition dynamic programming efficiently.

中等
70

爬楼梯

Climbing Stairs is a classic dynamic programming problem where you calculate distinct ways to reach the top using step t…

简单
72

编辑距离

Determine the minimum number of insertions, deletions, or replacements to transform one string into another using dynami…

中等
85

最大矩形

Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…

困难
87

扰乱字符串

Scramble String is a dynamic programming problem where we determine if one string can be scrambled to form another using…

困难
91

解码方法

Decode Ways is a dynamic programming problem focused on decoding a numeric string to letters using specific mappings.

中等
95

不同的二叉搜索树 II

Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.

中等
96

不同的二叉搜索树

Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.

中等
97

交错字符串

The Interleaving String problem requires determining if a string can be formed by interleaving two others, utilizing dyn…

中等
115

不同的子序列

Compute the number of distinct subsequences of one string matching another using precise state transition dynamic progra…

困难
118

杨辉三角

Generate the first numRows of Pascal's Triangle using dynamic programming with clear state transitions and array manipul…

简单
119

杨辉三角 II

Compute the specific row of Pascal's Triangle using efficient state transition dynamic programming with array-based upda…

简单
120

三角形最小路径和

Given a triangle, return the minimum path sum from top to bottom, moving to adjacent numbers in the row below.

中等
121

买卖股票的最佳时机

Maximize stock profit by identifying the optimal buy and sell days using dynamic programming.

简单
122

买卖股票的最佳时机 II

Maximize stock profit by using a greedy approach to buy and sell multiple times, with state transition dynamic programmi…

中等
123

买卖股票的最佳时机 III

Determine the maximum profit from at most two stock transactions using state transition dynamic programming on price arr…

困难
124

二叉树中的最大路径和

Calculate the maximum sum of any path in a binary tree by exploring all node sequences using DFS and dynamic programming…

困难
131

分割回文串

Find all possible palindrome partitioning of a string using backtracking and dynamic programming.

中等
132

分割回文串 II

Determine the minimum cuts required to partition a string into all palindromic substrings using dynamic programming tech…

困难
139

单词拆分

Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…

中等
140

单词拆分 II

Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.

困难
152

乘积最大子数组

Find the subarray with the largest product in an integer array using dynamic programming techniques.

中等
174

地下城游戏

Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …

困难
188

买卖股票的最佳时机 IV

Determine the maximum profit from at most k stock transactions using state transition dynamic programming on an array of…

困难
198

打家劫舍

Maximize the amount of money you can rob tonight without alerting the police by applying dynamic programming with state …

中等
213

打家劫舍 II

Maximize your loot by robbing houses arranged in a circle without alerting the police using dynamic programming.

中等
221

最大正方形

Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.

中等
233

数字 1 的个数

Compute the total number of digit one appearing in all numbers from 0 up to n using state transition dynamic programming…

困难
241

为运算表达式设计优先级

Solve Different Ways to Add Parentheses by splitting on each operator and memoizing every subexpression result list.

中等
264

丑数 II

Find the nth ugly number, where ugly numbers have prime factors limited to 2, 3, and 5.

中等
279

完全平方数

Perfect Squares asks for the least number of perfect squares summing to a given integer n using dynamic programming or B…

中等
300

最长递增子序列

Solve the Longest Increasing Subsequence problem using dynamic programming and binary search to efficiently find the sub…

中等
309

买卖股票的最佳时机含冷冻期

Maximize stock profit with cooldown restrictions using state transition dynamic programming to track buy, sell, and cool…

中等
312

戳气球

Burst Balloons is a hard dynamic programming problem requiring careful state transitions to maximize coins collected eff…

困难
313

超级丑数

Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …

中等
322

零钱兑换

Find the minimum number of coins needed to reach a target amount using dynamic programming state transitions efficiently…

中等
329

矩阵中的最长递增路径

Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.

困难
337

打家劫舍 III

Maximize the loot by robbing non-adjacent houses in a binary tree structure using dynamic programming and DFS.

中等
338

比特位计数

Compute the number of 1 bits for every integer from 0 to n using state transition dynamic programming for efficiency.

简单
343

整数拆分

Break an integer into the sum of positive integers to maximize the product using dynamic programming.

中等
354

俄罗斯套娃信封问题

Russian Doll Envelopes is a dynamic programming problem that involves finding the longest chain of envelopes that can be…

困难
357

统计各位数字都不同的数字个数

The problem asks to count numbers with unique digits from 0 to 10^n using dynamic programming, math, and backtracking te…

中等
368

最大整除子集

Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…

中等
375

猜数字大小 II

Minimize the maximum cost of guessing a number in a dynamic guessing game using optimal strategies.

中等
376

摆动序列

Find the longest wiggle subsequence in an integer array using state transition dynamic programming with greedy optimizat…

中等
377

组合总和 Ⅳ

Combination Sum IV asks to find the number of combinations that sum to a given target using elements from an array.

中等
392

判断子序列

Determine if one string is a subsequence of another using state transition dynamic programming for accurate character ma…

简单
396

旋转函数

Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.

中等
397

整数替换

Find the minimum number of operations to reduce a number to 1 by applying specific operations, using state transition dy…

中等
403

青蛙过河

Determine if a frog can cross a river using jumps constrained by previous step sizes in a dynamic programming state tran…

困难
410

分割数组的最大值

Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…

困难
413

等差数列划分

Count the number of arithmetic subarrays in a given integer array using dynamic programming.

中等
416

分割等和子集

Determine if an array can be partitioned into two subsets with equal sum using dynamic programming techniques.

中等
435

无重叠区间

Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…

中等
446

等差数列划分 II - 子序列

Count all arithmetic subsequences in an array using dynamic programming with precise state transitions for correctness.

困难
458

可怜的小猪

Find the minimum number of pigs required to determine the poisonous bucket within a set time using state transition dyna…

困难
464

我能赢吗

Determine if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…

中等
466

统计重复个数

This problem requires counting how many times a repeated string s2 fits as a subsequence within a repeated string s1 usi…

困难
467

环绕字符串中唯一的子字符串

Solve the 'Unique Substrings in Wraparound String' problem using dynamic programming with a state transition approach.

中等
472

连接词

Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …

困难
473

火柴拼正方形

The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…

中等
474

一和零

Solve the Ones and Zeroes problem using dynamic programming with state transition, focusing on array and string manipula…

中等
486

预测赢家

Predict the Winner involves two players taking turns to maximize their score by picking from either end of an array, opt…

中等
488

祖玛游戏

The Zuma Game involves clearing balls from the board using a limited hand, applying dynamic programming and state transi…

困难
494

目标和

Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…

中等
509

斐波那契数

Calculate the nth Fibonacci number using state transition dynamic programming and recursive techniques efficiently in in…

简单
514

自由之路

Determine the minimum rotations and button presses to spell a keyword on a circular dial using state transition dynamic …

困难
516

最长回文子序列

Find the length of the longest palindromic subsequence in a string using precise state transition dynamic programming.

中等
518

零钱兑换 II

Calculate the number of unique coin combinations to reach a target amount using state transition dynamic programming eff…

中等
526

优美的排列

The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…

中等
542

01 矩阵

The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…

中等
546

移除盒子

Maximize points by strategically removing contiguous same-colored boxes using state transition dynamic programming and m…

困难
552

学生出勤记录 II

The Student Attendance Record II problem explores counting valid student attendance sequences using dynamic programming …

困难
553

最优除法

Maximize the value of an expression by optimally placing parentheses for division operations.

中等
576

出界的路径数

Calculate the number of ways a ball can exit a grid using dynamic programming with state transitions for every move comb…

中等
583

两个字符串的删除操作

Find the minimum number of steps to make two strings equal by deleting characters, using dynamic programming.

中等
600

不含连续1的非负整数

Count non-negative integers up to n without consecutive ones in their binary representation using dynamic programming.

困难
629

K 个逆序对数组

The K Inverse Pairs Array problem focuses on counting arrays with exactly k inverse pairs using dynamic programming.

困难
638

大礼包

Minimize the cost of purchasing items using available special offers with state transition dynamic programming.

中等
639

解码方法 II

Decode Ways II is a challenging dynamic programming problem that involves decoding messages with digits and wildcard cha…

困难
646

最长数对链

Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…

中等
647

回文子串

Count all palindromic substrings in a given string using state transition dynamic programming for efficient evaluation.

中等
650

两个键的键盘

Minimize the number of operations to get exactly 'n' characters on the screen using two operations: Copy All and Paste.

中等
664

奇怪的打印机

Calculate the minimum turns a strange printer needs to print any string using state transition dynamic programming effic…

困难
673

最长递增子序列的个数

This problem challenges you to find the number of longest increasing subsequences in a given array of integers.

中等
678

有效的括号字符串

Solve the Valid Parenthesis String problem by leveraging state transition dynamic programming to handle parentheses and …

中等
688

骑士在棋盘上的概率

Calculate the probability that a knight remains on an n x n chessboard after making exactly k moves using dynamic progra…

中等
689

三个无重叠子数组的最大和

Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.

困难
691

贴纸拼词

Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…

困难
698

划分为k个相等的子集

Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…

中等
712

两个字符串的最小ASCII删除和

This problem focuses on minimizing the ASCII delete sum for two strings by using dynamic programming to find the lowest …

中等
714

买卖股票的最佳时机含手续费

Maximize stock trading profits accounting for per-transaction fees using state transition dynamic programming and greedy…

中等
718

最长重复子数组

Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.

中等
730

统计不同回文子序列

Count Different Palindromic Subsequences leverages dynamic programming to count non-empty palindromic subsequences in a …

困难
740

删除并获得点数

Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…

中等
741

摘樱桃

Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…

困难
746

使用最小花费爬楼梯

Compute the minimum cost to reach the top of a staircase using dynamic programming and step-by-step state transitions ef…

简单
764

最大加号标志

Find the largest axis-aligned plus sign in a binary grid with some mines using dynamic programming.

中等
773

滑动谜题

Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …

困难
787

K 站中转内最便宜的航班

Find the cheapest flight from a source to a destination with at most K stops using graph traversal techniques efficientl…

中等
788

旋转数字

Count all integers from 1 to n that transform into a different valid number when each digit is rotated 180 degrees using…

中等
790

多米诺和托米诺平铺

Calculate the number of ways to tile a 2xN board using dominoes and trominoes with precise state transitions.

中等
792

匹配子序列的单词数

Given a string s and a list of words, count how many words are subsequences of s using efficient array scanning and hash…

中等
799

香槟塔

Compute champagne levels in a pyramid of glasses using state transition dynamic programming for accurate distribution tr…

中等
801

使序列递增的最小交换次数

This problem involves finding the minimum number of swaps needed to make two sequences strictly increasing using dynamic…

困难
805

数组的均值分割

Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…

困难
808

分汤

Compute the probability that soup A empties before soup B using state transition dynamic programming efficiently.

中等
813

最大平均值和的分组

Maximize the sum of averages by partitioning an integer array into at most k contiguous subarrays using dynamic programm…

中等
818

赛车

Race Car is a dynamic programming problem where the goal is to find the shortest sequence of instructions to reach a tar…

困难
823

带因子的二叉树

Given an array of integers, find how many binary trees can be formed such that non-leaf nodes' values are the product of…

中等
828

统计子串中的唯一字符

Calculate the sum of unique characters in all substrings of a string using state transition dynamic programming.

困难
834

树中距离之和

The problem asks to compute the sum of distances between each node and all others in a tree structure using depth-first …

困难
837

新 21 点

Calculate the probability Alice reaches at most n points using state transition dynamic programming efficiently.

中等
838

推多米诺

In the "Push Dominoes" problem, you simulate the falling dominoes based on their initial states and determine their fina…

中等
845

数组中的最长山脉

Find the length of the longest subarray forming a mountain pattern using state transitions and two-pointer logic efficie…

中等
847

访问所有节点的最短路径

Solve the Shortest Path Visiting All Nodes problem by exploring dynamic programming, bit manipulation, and breadth-first…

困难
871

最低加油次数

Determine the minimum number of refueling stops needed to reach a target using dynamic programming and greedy strategies…

困难
873

最长的斐波那契子序列的长度

Find the length of the longest Fibonacci-like subsequence from a strictly increasing array of integers.

中等
877

石子游戏

Stone Game is a dynamic programming problem where players alternate taking stones from piles to maximize their score.

中等
879

盈利计划

Given a group of members and a list of crimes, count the profitable schemes that meet the profit and group constraints.

困难
887

鸡蛋掉落

Solve the Super Egg Drop problem using dynamic programming and binary search to minimize the number of moves required to…

困难
894

所有可能的真二叉树

Generate all possible full binary trees with n nodes, focusing on dynamic programming and binary tree traversal.

中等
898

子数组按位或操作

Compute the number of unique bitwise OR values from all non-empty subarrays using dynamic state transitions efficiently.

中等
902

最大为 N 的数字组合

The 'Numbers At Most N Given Digit Set' problem requires calculating how many numbers can be formed using a given digit …

困难
903

DI 序列的有效排列

The problem asks to find the number of valid permutations for a given DI sequence string using dynamic programming and s…

困难
907

子数组的最小值之和

Calculate the sum of minimum values across all subarrays of a given array modulo 10^9 + 7.

中等
913

猫和老鼠

Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…

困难
918

环形子数组的最大和

Find the maximum sum of a circular subarray using state transition dynamic programming, optimizing for wraparound cases …

中等
920

播放列表的数量

Solve the Number of Music Playlists problem with dynamic programming, focusing on state transitions and combinatorics to…

困难
926

将字符串翻转到单调递增

Minimize the number of flips needed to make a binary string monotone increasing using dynamic programming.

中等
931

下降路径最小和

Minimum Falling Path Sum is a matrix dynamic programming problem where each cell depends on three reachable cells above …

中等
935

骑士拨号器

Solve the Knight Dialer problem using state transition dynamic programming to efficiently calculate valid number paths f…

中等
940

不同的子序列 II

Find the number of distinct non-empty subsequences of a string using dynamic programming and state transitions.

困难
943

最短超级串

This problem requires constructing the shortest string containing all input words using state transition dynamic program…

困难
956

最高的广告牌

Solve the Tallest Billboard problem by using dynamic programming to find the maximum equal height for two disjoint rod s…

困难
960

删列造序 III

The problem requires minimizing deletions to ensure all strings are lexicographically sorted. Use dynamic programming fo…

困难
964

表示数字的最少运算符

Compute the minimum number of arithmetic operators to form a target using repeated x with addition, subtraction, multipl…

困难
968

监控二叉树

Determine the minimum number of cameras required to monitor every node in a binary tree using efficient DFS and state tr…

困难
975

奇偶跳

Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…

困难
978

最长湍流子数组

Find the length of the longest subarray where element comparisons alternate, using state transition dynamic programming …

中等
983

最低票价

Solve the Minimum Cost For Tickets problem using state transition dynamic programming for optimal travel ticket purchase…

中等
996

平方数组的数目

Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…

困难
1000

合并石头的最低成本

Minimize the cost to merge stones with k consecutive piles using dynamic programming to achieve the optimal solution.

困难
1012

至少有 1 位重复的数字

Solve Numbers With Repeated Digits by counting unique-digit numbers up to n, then subtracting from n using digit DP.

困难
1014

最佳观光组合

Compute the maximum sightseeing score efficiently using state transition dynamic programming and single-pass array itera…

中等
1024

视频拼接

Solve the "Video Stitching" problem using state transition dynamic programming to cover a sporting event with minimum cl…

中等
1025

除数博弈

Divisor Game is a game theory problem where players take turns subtracting divisors of a number n until one player loses…

简单
1027

最长等差数列

Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.

中等
1031

两个无重叠子数组的最大和

Find the maximum sum of two non-overlapping subarrays by efficiently using state transition dynamic programming.

中等
1035

不相交的线

The Uncrossed Lines problem involves finding the maximum number of non-intersecting lines that can be drawn between two …

中等
1039

多边形三角剖分的最低得分

Compute the minimum total score to triangulate a convex polygon using state transition dynamic programming on vertex val…

中等
1043

分隔数组以得到最大和

Partition an array into subarrays of length at most k, replacing each with its maximum to maximize total sum efficiently…

中等
1048

最长字符串链

Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…

中等
1049

最后一块石头的重量 II

In the 'Last Stone Weight II' problem, you need to find the minimal possible stone weight after a series of smashes usin…

中等
1092

最短公共超序列

Compute the shortest string containing both given strings as subsequences using state transition dynamic programming eff…

困难
1105

填充书架

Determine the minimum total height of a bookcase by placing books in order using state transition dynamic programming.

中等
1125

最小的必要团队

Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…

困难
1130

叶值的最小代价生成树

Compute the minimum sum of non-leaf nodes in a binary tree formed from array leaves using dynamic programming efficientl…

中等
1137

第 N 个泰波那契数

Compute the N-th Tribonacci number using state transition dynamic programming with careful memoization and iterative upd…

简单
1139

最大的以 1 为边界的正方形

Find the largest square of 1s with 1s on its borders in a binary grid using dynamic programming.

中等
1140

石子游戏 II

Stone Game II is a dynamic programming problem where Alice and Bob alternate taking stones from piles to maximize their …

中等
1143

最长公共子序列

Find the length of the longest common subsequence between two strings using state transition dynamic programming for eff…

中等
1147

段式回文

Solve the "Longest Chunked Palindrome Decomposition" problem by using dynamic programming and string manipulation techni…

困难
1155

掷骰子等于目标和的方法数

Calculate the number of ways to roll n dice with k faces to reach a target sum using state transition dynamic programmin…

中等
1162

地图分析

Find the farthest water cell from land in a grid and return the Manhattan distance using state transition dynamic progra…

中等
1186

删除一次得到子数组最大和

Find the maximum sum of a subarray with at most one deletion in this dynamic programming problem.

中等
1187

使数组严格递增

Determine the minimum operations to transform arr1 into a strictly increasing sequence using values from arr2 efficientl…

困难
1191

K 次串联后最大子数组之和

Solve the K-Concatenation Maximum Sum problem using dynamic programming and optimal sub-array sum calculation.

中等
1218

最长定差子序列

Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.

中等
1220

统计元音字母序列的数目

Count Vowels Permutation requires computing the number of valid vowel strings of length n using state transition dynamic…

困难
1223

掷骰子模拟

Calculate all valid sequences of n dice rolls with consecutive roll constraints using state transition dynamic programmi…

困难
1227

飞机座位分配概率

Calculate the probability that the last passenger sits in their assigned seat using state transition dynamic programming…

中等
1235

规划兼职工作

Compute the maximum profit from non-overlapping jobs using state transition dynamic programming with sorted arrays and b…

困难
1255

得分最高的单词集合

Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…

困难
1262

可被三整除的最大和

Find the maximum sum divisible by three from a given array using dynamic programming and state transition.

中等
1269

停在原地的方案数

Compute the exact number of ways to remain at index 0 after given steps using state transition dynamic programming.

困难
1277

统计全为 1 的正方形子矩阵

Count the number of square submatrices with all ones in a given binary matrix using dynamic programming.

中等
1278

分割回文串 III

Find the minimal character changes to split a string into k palindromes using precise dynamic programming state transiti…

困难
1289

下降路径最小和 II

Find the minimum sum of a falling path in a square matrix using dynamic programming while avoiding same-column selection…

困难
1301

最大得分的路径数目

Calculate the maximum score path and count all valid routes in a square board with obstacles using dynamic programming.

困难
1312

让字符串成为回文串的最少插入次数

The problem asks to find the minimum number of insertions to convert a string into a palindrome using dynamic programmin…

困难
1320

二指输入的的最小距离

Calculate the minimum total distance to type a word using two fingers on a keyboard, applying dynamic programming.

困难
1326

灌溉花园的最少水龙头数目

Determine the minimum number of taps to water an entire garden using state transition dynamic programming and interval c…

困难
1334

阈值距离内邻居最少的城市

Find the city with the fewest neighbors within a given threshold distance using dynamic programming.

中等
1335

工作计划的最低难度

Schedule jobs into multiple days to minimize the difficulty of the schedule using dynamic programming and state transiti…

困难
1340

跳跃游戏 V

Jump Game V is a hard dynamic programming problem that focuses on maximizing jumps between indices in an array.

困难
1349

参加考试的最大学生数

Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…

困难
1359

有效的快递序列数目

Count all valid pickup and delivery sequences for n orders where deliveries occur after pickups using dynamic programmin…

困难
1363

形成三的最大倍数

Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…

困难
1372

二叉树中的最长交错路径

Find the longest ZigZag path in a binary tree using depth-first search and dynamic programming for precise node state tr…

中等
1373

二叉搜索子树的最大键值和

Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.

困难
1387

将整数按权重排序

Sort integers in a range based on their power value using dynamic programming and memoization, handling ties with ascend…

中等
1388

3n 块披萨

Maximize your pizza slice sum from a 3n-sized circular array using state transition dynamic programming efficiently.

困难
1395

统计作战单位数

Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…

中等
1397

找到所有好字符串

Find all good strings between two given strings without including a specified evil substring using dynamic programming.

困难
1402

做菜顺序

Maximize the sum of like-time coefficients by optimally choosing dishes to prepare in this dynamic programming problem.

困难
1406

石子游戏 III

Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.

困难
1411

给 N x 3 网格图涂色的方案数

Calculate the number of ways to paint a grid of size n x 3 with distinct adjacent colors using dynamic programming.

困难
1416

恢复数组

Calculate the number of arrays that can be restored from a string of digits where each number is within [1, k].

困难
1420

生成数组

This problem asks to build an array where the maximum element is found using exactly K comparisons, with dynamic program…

困难
1425

带限制的子序列和

Solve the Constrained Subsequence Sum problem using dynamic programming, sliding window, and priority queues to maximize…

困难
1434

每个人戴不同帽子的方案数

Calculate all unique assignments of hats to people using state transition dynamic programming with bitmasking for collis…

困难
1444

切披萨的方案数

This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…

困难
1449

数位成本和为目标值的最大数字

Maximize the integer you can paint with given digit costs under a target sum, using dynamic programming to optimize the …

困难
1458

两个子序列的最大点积

Solve Max Dot Product of Two Subsequences with state transition dynamic programming that enforces a non-empty pairing de…

困难
1463

摘樱桃 II

Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…

困难
1467

两个盒子中球的颜色数相同的概率

Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…

困难
1473

粉刷房子 III

Solve Paint House III using state transition dynamic programming to minimize painting costs while forming exact neighbor…

困难
1477

找两个和为目标值且不重叠的子数组

Find two non-overlapping sub-arrays with a given target sum and return the minimal total length efficiently using array …

中等
1478

安排邮筒

Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…

困难
1483

树节点的第 K 个祖先

Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.

困难
1493

删掉一个元素以后全为 1 的最长子数组

Solve LeetCode 1493 by tracking runs of 1s around one deletion using a tight sliding window or state transition DP.

中等
1494

并行课程 II

Determine the minimum semesters to complete all courses with prerequisites using state transition dynamic programming an…

困难
1504

统计全 1 子矩形

Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…

中等
1510

石子游戏 IV

Stone Game IV requires predicting the winner using state transition dynamic programming with careful consideration of pe…

困难
1524

和为奇数的子数组数目

Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.

中等
1525

字符串的好分割数目

Count all valid splits of a string where left and right substrings have equal distinct characters, using efficient state…

中等
1526

形成目标数组的子数组最少增加次数

The problem asks for the minimum number of operations to transform an initial array of zeros into a target array using s…

困难
1531

压缩字符串 II

Solve String Compression II with dynamic programming that tracks deletions, run boundaries, and digit-length jumps in co…

困难
1537

最大得分

Find the maximum possible score from two sorted arrays with a dynamic programming approach, leveraging partitioning and …

困难
1547

切棍子的最小成本

Find the minimum cost to cut a stick into segments at specified positions using dynamic programming and sorting.

困难
1553

吃掉 N 个橘子的最少天数

Find the minimum number of days to eat n oranges using state transition dynamic programming with memoization.

困难
1563

石子游戏 V

In Stone Game V, Alice divides stones into rows to maximize her score, using a dynamic programming approach to try all d…

困难
1567

乘积为正数的最长子数组长度

Given an array, find the maximum length of a subarray with a positive product using dynamic programming.

中等
1569

将子数组重新排序得到同一个二叉搜索树的方案数

Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.

困难
1575

统计所有可行路径

This problem requires counting all possible routes between cities using fuel efficiently with state transition dynamic p…

困难
1578

使绳子变成彩色的最短时间

Minimize the time Bob needs to remove balloons to make a rope colorful using dynamic programming with state transitions.

中等
1594

矩阵的最大非负积

Find the maximum non-negative product path in a matrix using dynamic programming and state transition.

中等
1595

连通两组点的最小成本

Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.

困难
1611

使整数变为 0 的最少操作次数

Compute the minimum number of one-bit operations to convert a given integer to zero using state transition dynamic progr…

困难
1617

统计子树中城市之间最大距离

This problem asks you to count subtrees in a tree structure where the maximum distance between any two cities matches sp…

困难
1621

大小为 K 的不重叠线段的数目

Count all valid arrangements of k non-overlapping line segments on n points using state transition dynamic programming.

中等
1626

无矛盾的最佳球队

Find the highest score basketball team by choosing players without conflicts in age and score using dynamic programming.

中等
1638

统计只差一个字符的子串数目

Count all substrings from s that differ by exactly one character from some substring in t using precise substring compar…

中等
1639

通过给定词典构造目标字符串的方案数

Calculate the number of ways to form a target string using words of equal length via state transition dynamic programmin…

困难
1641

统计字典序元音字符串的数目

Calculate the number of length-n strings with vowels only that are sorted lexicographically using state transitions.

中等
1643

第 K 条最小指令

Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…

困难
1653

使字符串平衡的最少删除次数

Determine the minimum number of deletions to transform a string of 'a' and 'b' into a balanced order using DP.

中等
1654

到家的最少跳跃次数

Find the minimum number of jumps needed to reach a target position while avoiding forbidden positions.

中等
1655

分配重复整数

Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…

困难
1659

最大化网格幸福感

Maximize Grid Happiness is a dynamic programming problem focusing on state transitions with bitmasking to maximize happi…

困难
1668

最大重复子字符串

Find the maximum number of times a given word repeats consecutively in a string using state transition dynamic programmi…

简单
1671

得到山形数组的最少删除次数

Solve the problem of finding the minimum number of removals to make a given array a mountain array using dynamic program…

困难
1681

最小不兼容性

Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.

困难
1687

从仓库到码头运输箱子

Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…

困难
1690

石子游戏 VII

Maximize score difference in a two-player turn-based stone removal game using state transition dynamic programming.

中等
1691

堆叠长方体的最大高度

Maximize the height of stacked cuboids by strategically rotating and stacking them using dynamic programming.

困难
1696

跳跃游戏 VI

Jump Game VI challenges you to maximize your score while jumping through an array using state transition dynamic program…

中等
1723

完成所有工作的最短时间

Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…

困难
1728

猫和老鼠 II

Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…

困难
1735

生成乘积数组的方案数

Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…

困难
1745

分割回文串 IV

The Palindrome Partitioning IV problem asks you to determine if a string can be split into three palindromic substrings.

困难
1749

任意子数组和的绝对值的最大值

Solve for the maximum absolute sum of any subarray using dynamic programming and understanding state transitions.

中等
1751

最多可以参加的会议数目 II

Determine the maximum sum of event values you can collect by attending at most k non-overlapping events using DP.

困难
1755

最接近目标值的子序列和

Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…

困难
1770

执行乘法运算的最大分数

Solve the Maximum Score from Performing Multiplication Operations problem using dynamic programming and state transition…

困难
1771

由子序列构造的最长回文串的长度

Maximize Palindrome Length From Subsequences explores dynamic programming to construct the longest palindrome from two s…

困难
1774

最接近目标价格的甜点成本

Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…

中等
1786

从第一个节点出发到最后一个节点的受限路径数

Solve the problem of finding the number of restricted paths in a weighted undirected graph, leveraging graph algorithms …

中等
1787

使所有区间的异或结果为零

Determine the minimum changes needed in an array so all size-k segments XOR to zero using DP and bit manipulation.

困难
1799

N 次操作后的最大分数和

Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …

困难
1815

得到新鲜甜甜圈的最多组数

Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…

困难
1824

最少侧跳次数

Solve the Minimum Sideway Jumps problem using state transition dynamic programming to minimize side jumps while navigati…

中等
1857

有向图中最大颜色值

Compute the maximum color frequency along any valid path in a directed graph using topological ordering and dynamic prog…

困难
1866

恰有 K 根木棍可以看到的排列数目

Calculate the number of arrangements of n uniquely-sized sticks so exactly k sticks are visible using dynamic programmin…

困难
1871

跳跃游戏 VII

The problem asks to determine if we can reach the last index of a binary string, with a set range of jumps between indic…

中等
1872

石子游戏 VIII

Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …

困难
1879

两个数组最小的异或值之和

Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.

困难
1883

准时抵达会议现场的最小跳过休息次数

Solve the problem of minimizing skips while traveling to arrive on time, using dynamic programming and state transitions…

困难
1884

鸡蛋掉落-两枚鸡蛋

Determine the minimum drops needed to find the critical floor using 2 eggs with optimized state transition dynamic progr…

中等
1888

使二进制字符串字符交替的最少反转次数

Find the minimum number of flips to make a binary string alternate, using state transition dynamic programming.

中等
1896

反转表达式值的最少操作次数

Determine the minimum operations to change a boolean expression's result using state transition dynamic programming effi…

困难
1900

最佳运动员的比拼回合

This problem requires finding the earliest and latest rounds where two players compete using dynamic programming with st…

困难
1911

最大交替子序列和

Maximize alternating subsequence sum with dynamic programming and state transitions in an array.

中等
1916

统计为蚁群构筑房间的不同顺序

Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…

困难
1928

规定时间内到达终点的最小花费

Minimize the travel cost in a graph while adhering to a time constraint using state transition dynamic programming.

困难
1931

用三种不同颜色为网格涂色

Count the number of ways to paint a grid using three colors while ensuring adjacent cells have different colors.

困难
1937

扣分后的最大得分

Maximize your points in a matrix by selecting cells row by row while accounting for distance penalties using dynamic pro…

中等
1947

最大兼容性评分和

Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…

中等
1955

统计特殊子序列的数目

Learn to count all valid special subsequences in an array using state transition dynamic programming efficiently and cor…

困难
1959

K 次调整数组大小浪费的最小总空间

Find the minimum total space wasted in a dynamic array with at most k resizing operations.

中等
1976

到达目的地的方案数

Find the number of ways to travel from intersection 0 to n - 1 in the shortest time, using a graph-based approach.

中等
1977

划分数字的方案数

Calculate the number of valid non-decreasing integer sequences from a string using state transition dynamic programming …

困难
1981

最小化目标值与所选元素的差

This problem asks to select one element per row to minimize the absolute difference from a target sum using dynamic prog…

中等
1986

完成任务的最少工作时间段

Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.

中等
1987

不同的好子序列数目

Find the number of unique good subsequences of a binary string using dynamic programming and modular arithmetic.

困难
1994

好子集的数目

Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.

困难
1997

访问完所有房间的第一天

Calculate the first day you have visited all rooms using state transition dynamic programming on the nextVisit array.

中等
2002

两个回文子序列长度的最大乘积

Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…

中等
2003

每棵子树内缺失的最小基因值

Determine the smallest missing genetic value in each subtree using binary-tree traversal and precise state tracking effi…

困难
2008

出租车的最大盈利

Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.

中等
2019

解出数学表达式的学生分数

Calculate student scores for a single-digit math expression using state transition dynamic programming to track all vali…

困难
2035

将数组分成两个数组并最小化数组和的差

Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…

困难
2050

并行课程 III

Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…

困难
2054

两个最好的不重叠活动

Maximize the total value of at most two non-overlapping events using state transition dynamic programming efficiently.

中等
2060

同源字符串检测

Determine if there exists an original string that could produce both encoded inputs using state transition dynamic progr…

困难
2063

所有子字符串中的元音

Compute the total number of vowels in all substrings of a given string using efficient state transition dynamic programm…

中等
2086

喂食仓鼠的最小食物桶数

Find the minimum number of food buckets required to feed all hamsters, using dynamic programming and greedy techniques.

中等
2088

统计农场中肥沃金字塔的数目

Solve Count Fertile Pyramids in a Land with matrix DP that measures the tallest pyramid rooted at each fertile cell.

困难
2100

适合野炊的日子

Find good days to rob the bank by identifying days with non-increasing and non-decreasing guard counts using dynamic pro…

中等
2110

股票平滑下跌阶段的数目

Count all contiguous periods where stock prices descend smoothly by exactly one using dynamic programming techniques.

中等
2140

解决智力问题

Maximize points in an exam with state transition dynamic programming by deciding whether to solve or skip each question.

中等
2147

分隔长廊的方案数

Calculate the number of ways to split a corridor into sections with exactly two seats using dynamic programming efficien…

困难
2163

删除元素后和的最小差值

Minimize the difference between sums after removing n elements from a 3n array by dividing the remaining elements into t…

困难
2167

移除所有载有违禁货物车厢所需的最少时间

Determine the minimum time to remove all cars with illegal goods using state transition dynamic programming efficiently.

困难
2172

数组的最大与和

Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.

困难
2188

完成比赛的最少时间

Minimize the time to complete a race with tire swaps using dynamic programming and state transitions.

困难
2209

用地毯覆盖后的最少白色砖块

Find the minimum number of white tiles visible after optimally placing carpets using state transition dynamic programmin…

困难
2218

从栈中取出 K 个硬币的最大面值和

Optimize coin selection across multiple piles using state transition dynamic programming to achieve the maximum wallet v…

困难
2222

选择建筑的方案数

Solve Number of Ways to Select Buildings by counting alternating 3-building patterns with state transitions over the bin…

中等
2262

字符串的总引力

Calculate the total appeal of all substrings by counting distinct characters efficiently using state transition DP and h…

困难
2266

统计打字方案数

Calculate the total number of possible original texts from a pressed key sequence using state transition dynamic program…

中等
2267

检查是否有合法括号字符串路径

Check if there exists a valid parentheses string path in a given grid using state transition dynamic programming.

困难
2272

最大波动的子字符串

Find the largest variance possible in any substring of a given string using dynamic programming.

困难
2304

网格中的最小路径代价

Minimize the cost of a path in a grid while considering move costs for each step.

中等
2305

公平分发饼干

The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…

中等
2310

个位数字为 K 的整数之和

Determine the minimum set of positive integers whose units digits match k and sum exactly to num using DP patterns.

中等
2311

小于等于 K 的最长二进制子序列

Find the longest subsequence in a binary string that forms a number less than or equal to a given integer k.

中等
2312

卖木头块

Maximize your profit by cutting a wooden piece into smaller parts based on given prices and dimensions.

困难
2318

不同骰子序列的数目

Calculate the number of distinct sequences of dice rolls based on specific conditions using dynamic programming.

困难
2320

统计放置房子的方式数

This problem asks you to calculate the number of ways to place houses along a street while preventing adjacent houses on…

中等
2321

拼接数组的最大分数

Maximize the score of two arrays by splicing and swapping a subarray using dynamic programming.

困难
2327

知道秘密的人数

Calculate how many people know a secret over n days using state transition dynamic programming and careful simulation of…

中等
2328

网格图中递增路径的数目

Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…

困难
2338

统计理想数组的数目

This problem involves counting the number of ideal arrays of a given length under certain conditions using state transit…

困难
2369

检查数组是否存在有效划分

This problem challenges you to determine if an array can be partitioned into valid subarrays using dynamic programming.

中等
2370

最长理想子序列

The Longest Ideal Subsequence problem involves finding the longest subsequence where each character has a difference of …

中等
2376

统计特殊整数

Count the number of special integers in the interval [1, n] where digits of each integer are distinct.

困难
2380

二进制字符串重新安排顺序需要的时间

Calculate the exact seconds required to convert all 01 pairs into 10 in a binary string using state transitions.

中等
2400

恰好移动 k 步到达某一位置的方法数目

Find the number of ways to reach a position after exactly k steps on an infinite number line using dynamic programming.

中等
2407

最长递增子序列 II

Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…

困难
2420

找到所有好下标

Identify all indices in an array where the k-length prefix is non-increasing and the k-length suffix is non-decreasing.

中等
2430

对字母串可执行的最大删除数

Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …

困难
2435

矩阵中和能被 K 整除的路径

Compute all paths in a matrix where the sum of elements is divisible by k using state transition dynamic programming eff…

困难
2439

最小化数组中的最大值

Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …

中等
2463

最小移动总距离

Optimize the total distance traveled by robots to factories using dynamic programming, sorting, and state transitions.

困难
2466

统计构造好字符串的方案数

Count the number of ways to build good binary strings using dynamic programming with state transitions.

中等
2472

不重叠回文子字符串的最大数目

Find the maximum number of non-overlapping palindromic substrings of at least length k in a string using dynamic program…

困难
2478

完美分割的方案数

The problem involves finding the number of beautiful partitions in a string with dynamic programming and state transitio…

困难
2484

统计回文子序列数目

Count the number of palindromic subsequences of length 5 in a given string of digits.

困难
2501

数组中最长的方波

Find the length of the longest subsequence where each element is a perfect square of its previous one.

中等
2518

好分区的数目

Calculate the number of great partitions of an array using state transition dynamic programming with careful sum constra…

困难
2522

将字符串分割成值不超过 K 的子字符串

Determine the minimum number of substrings from a numeric string such that each substring value does not exceed k using …

中等
2538

最大价值和与最小价值和的差值

Compute the maximum difference between any path price sum in a tree using binary-tree traversal and state tracking effic…

困难
2547

拆分数组的最小代价

Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…

困难
2552

统计上升四元组

Given a permutation of numbers, count the number of increasing quadruplets using dynamic programming.

困难
2556

二进制矩阵中翻转最多一次使路径不连通

Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…

中等
2560

打家劫舍 IV

House Robber IV requires calculating minimum maximum money the robber can take using state transition dynamic programmin…

中等
2571

将整数减少到零需要的最少操作数

Compute the minimum number of operations to reduce a positive integer to zero using additions or subtractions of powers …

中等
2572

无平方子集计数

Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…

中等
2573

找出对应 LCP 矩阵的字符串

Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.

困难
2581

统计可能的树根数目

Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.

困难
2585

获得分数的方法数

Find the number of ways to earn exactly target points using multiple types of exam questions with distinct marks.

困难
2597

美丽子集的数目

Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…

中等
2606

找到最大开销的子字符串

Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…

中等
2616

最小化数对的最大差值

Minimize the Maximum Difference of Pairs seeks to optimize the maximum pairwise difference in a set of index pairs from …

中等
2617

网格图中最少访问的格子数

Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…

困难
2645

构造有效字符串的最少插入数

Determine the minimum insertions required to transform a given string into repeated concatenations of 'abc' using dynami…

中等
2646

最小化旅行的价格总和

Calculate the minimum total cost of multiple trips on a tree by selectively halving node prices using DFS frequency coun…

困难
2673

使二叉树所有路径值相等的最小代价

Minimize the cost increments required to equalize path costs in a binary tree from root to leaves.

中等
2681

英雄的力量

Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…

困难
2684

矩阵中移动的最大次数

Maximize the number of moves in a grid starting from the first column using state transition dynamic programming.

中等
2707

字符串中的额外字符

The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…

中等
2708

一个小组的最大实力值

Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…

中等
2712

使所有字符相等的最小成本

Find the minimum cost to make all characters of a binary string equal by performing two types of operations.

中等
2713

矩阵中严格递增的单元格数

Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…

困难
2719

统计整数数目

Count of Integers challenges you to find the number of integers with a digit sum between a given range using dynamic pro…

困难
2741

特别的排列

Count the number of special permutations for a given array using dynamic programming and bit manipulation.

中等
2742

给墙壁刷油漆

Compute the minimum cost to paint all walls using a paid and free painter with state transition dynamic programming.

困难
2745

构造最长的新字符串

Maximize the length of a string built from AA, BB, and AB without creating triple repeats using DP and greedy logic.

中等
2746

字符串连接删减字母

Solve the Decremental String Concatenation problem by applying dynamic programming to minimize string length after conca…

中等
2750

将数组划分成若干好子数组的方式

Calculate the number of ways to partition a binary array into good subarrays using state transition dynamic programming …

中等
2767

将字符串分割为最少的美丽子字符串

Partition a binary string into the fewest beautiful substrings using state transition dynamic programming and careful su…

中等
2770

达到末尾下标所需的最大跳跃次数

Find the maximum number of jumps to reach the last index using state transition dynamic programming efficiently in array…

中等
2771

构造最长非递减子数组

Maximize the length of a non-decreasing subarray by optimally choosing elements from two arrays using dynamic programmin…

中等
2786

访问数组中的位置使分数最大

Maximize your score by visiting positions in an array while handling penalties for parity changes efficiently with DP.

中等
2787

将一个数字表示成幂的和的方案数

Compute the number of ways to express an integer as a sum of unique powers using state transition dynamic programming ef…

中等
2791

树中可以形成回文的路径数

This problem asks you to count all node pairs in a tree whose path characters can be rearranged into a palindrome using …

困难
2801

统计范围内的步进数字数目

Count the stepping numbers in a range using dynamic programming with state transitions between digits.

困难
2809

使数组和小于等于 x 的最少时间

Calculate the minimum seconds to reduce the array sum to at most x using optimal single-time reductions per index effici…

困难
2811

判断是否能拆分数组

Determine whether an array can be fully split into single-element subarrays using a state transition dynamic programming…

中等
2826

将三个组排序

Determine the minimum removals to make an array of 1s, 2s, and 3s non-decreasing using dynamic programming transitions.

中等
2827

范围中美丽整数的数目

Count all integers in a given range that have equal even and odd digits and are divisible by k using DP.

困难
2830

销售利润最大化

Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…

中等
2836

在传球游戏中最大化函数值

Maximize the total score in a ball-passing game by selecting the best starting player using state transition dynamic pro…

困难
2850

将石头分散到网格图的最少移动次数

Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…

中等
2851

字符串转换

Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.

困难
2858

可以到达每一个节点的最少边反转次数

This problem requires solving a graph traversal with edge reversals to ensure every node is reachable in a tree-like str…

困难
2867

统计树中的合法路径数目

Count Valid Paths in a Tree involves finding paths with exactly one prime number in a tree of n nodes.

困难
2876

有向图访问计数

Count Visited Nodes in a Directed Graph uses dynamic programming to solve graph traversal and node visitation counting e…

困难
2896

执行操作使两个字符串相等

Apply Operations to Make Two Strings Equal involves transforming binary strings with a cost-based dynamic programming ap…

中等
2900

最长相邻不相等子序列 I

Find the longest alternating subsequence in a string array based on a binary group array.

简单
2901

最长相邻不相等子序列 II

Find the longest subsequence of indices such that the corresponding strings have a valid Hamming distance and group cons…

中等
2902

和带限制的子多重集合的数目

This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.

困难
2911

得到 K 个半回文串的最少修改次数

Minimize the number of letter changes to partition a string into k semi-palindromes using dynamic programming and two po…

困难
2915

和为目标值的最长子序列的长度

Find the length of the longest subsequence in an array that sums to a target value, using dynamic programming.

中等
2916

子数组不同元素数目的平方和 II

Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.

困难
2919

使数组变美的最小增量运算数

Optimize the number of increment operations to make an array beautiful by ensuring subarrays of size 3 or more meet the …

中等
2920

收集所有金币可获得的最大积分

Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.

困难
2925

在树上执行操作以后得到的最大分数

Solve Maximum Score After Applying Operations on a Tree by turning healthy-path constraints into subtree DP and forced-v…

中等
2926

平衡子序列的最大和

Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…

困难
2930

重新排列后包含指定子字符串的字符串数目

Calculate how many strings of length n can be rearranged to contain "leet" using dynamic programming and combinatorics.

中等
2944

购买水果需要的最少金币数

Calculate the minimum coins to buy fruits using state transition dynamic programming while handling rewards and purchase…

中等
2945

找到最大非递减数组的长度

Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…

困难
2957

消除相邻近似相等字符

Minimize operations to remove adjacent almost-equal characters using dynamic programming and greedy methods.

中等
2973

树中每个节点放置的金币数目

Determine the exact number of coins to place on each tree node using subtree cost products and DFS tracking.

困难
2977

转换字符串的最小成本 II

Compute the minimum cost to transform source into target using substring replacements with given costs efficiently using…

困难
2998

使 X 和 Y 相等的最少操作次数

Determine the minimum operations to make two integers equal using increment, decrement, and division efficiently with DP…

中等
2999

统计强大整数的数目

Count the number of powerful integers in a given range by applying state transition dynamic programming with constraints…

困难
3003

执行操作后的最大分割数量

Maximizing the number of partitions in a string after changing one character and applying partitioning operations using …

困难
3007

价值和小于等于 K 的最大数字

Find the greatest number whose accumulated price, based on binary set bit positions, is less than or equal to k.

中等
3040

相同分数的最大操作数目 II

This problem asks to maximize operations on an integer array where all deletions produce the same score using dynamic pr…

中等
3041

修改数组后最大化数组中的连续元素数目

Solve Maximize Consecutive Elements in an Array After Modification by sorting and using state transition DP on value and…

困难
3068

最大节点价值之和

Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…

困难
3077

K 个不相交子数组的最大能量值

Solve Maximum Strength of K Disjoint Subarrays with dynamic programming that tracks segment state, sign changes, and wei…

困难
3082

求出所有子序列的能量和

Find the sum of the power of all subsequences of an integer array where their sum equals a given number.

困难
3098

求出所有子序列的能量和

Compute the sum of powers for all subsequences of length k using state transition dynamic programming efficiently.

困难
3117

划分数组得到最小的值之和

Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.

困难
3122

使矩阵满足条件的最少操作次数

This problem asks to find the minimum number of operations on a 2D grid using state transition dynamic programming effic…

中等
3129

找出所有稳定的二进制数组 I

Find all stable binary arrays of a given number of 0's, 1's, and limit using dynamic programming and state transitions.

中等
3130

找出所有稳定的二进制数组 II

Compute the number of stable binary arrays using state transition dynamic programming with exact zero, one, and limit co…

困难
3144

分割字符频率相等的最少子字符串

Partition a string into substrings with equal character frequencies using dynamic programming and state transitions.

中等
3148

矩阵中的最大得分

Maximize the score in a grid by making moves to the bottom or right, using state transition dynamic programming.

中等
3149

找出分数最低的排列

Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…

困难
3154

到达第 K 级台阶的方案数

Determine the total number of ways to reach the k-th stair using a state transition dynamic programming approach with co…

困难
3165

不包含相邻元素的子序列的最大和

Compute the maximum sum of a subsequence where no two adjacent elements are selected after each array update efficiently…

困难
3176

求出最长好子序列 I

Find the maximum length of a good subsequence by scanning arrays and using hash lookups for value remapping efficiently.

中等
3177

求出最长好子序列 II

Determine the maximum length of a good subsequence in an integer array using array scanning and hash lookup efficiently.

困难
3180

执行操作可获得的最大总奖励 I

Optimize the total reward by choosing operations on array indices using state transition dynamic programming techniques …

中等
3181

执行操作可获得的最大总奖励 II

Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …

困难
3186

施咒的最大总伤害

Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…

中等
3192

使二进制数组全部等于 1 的最少操作次数 II

Solve the Minimum Operations to Make Binary Array Elements Equal to One II using state transition dynamic programming ef…

中等
3193

统计逆序对的数目

Count the number of valid permutations satisfying inversion constraints using state transition dynamic programming.

困难
3196

最大化子数组的总成本

Maximize the total cost of alternating subarrays using dynamic programming to efficiently split an array into optimal su…

中等
3201

找出有效子序列的最大长度 I

Find the longest valid subsequence in an array of integers using dynamic programming to handle different patterns of seq…

中等
3202

找出有效子序列的最大长度 II

Determine the maximum length of a valid subsequence using state transition dynamic programming with careful modulo const…

中等
3213

最小代价构造字符串

This problem asks you to construct a target string using given words at minimal cost using dynamic programming technique…

困难
3218

切蛋糕的最小总开销 I

In this problem, you need to minimize the cost of cutting a cake into 1x1 pieces using vertical and horizontal cuts.

中等
3225

网格图操作后的最大分数

Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…

困难
3229

使数组等于目标数组所需的最少操作次数

This problem requires calculating the minimum number of operations to transform one array into another using state trans…

困难
3241

标记所有节点需要的时间

Calculate the time taken to mark all nodes in a tree, starting from any node with time t=0.

困难
3250

单调数组对的数目 I

Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.

困难
3251

单调数组对的数目 II

This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…

困难
3256

放三个车的价值之和最大 I

Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.

困难
3257

放三个车的价值之和最大 II

Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.

困难
3259

超级饮料的最大强化能量

Maximize energy boost from two drinks with a state transition dynamic programming approach.

中等
3260

找出最大的 N 位 K 回文数

Compute the largest n-digit integer divisible by k that forms a palindrome using state transition dynamic programming te…

困难
3276

选择矩阵中单元格的最大得分

Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.

困难
3277

查询子数组最大异或值

Solve the Maximum XOR Score Subarray Queries problem using state transition dynamic programming for optimal subarray com…

困难
3287

求出数组中最大序列值

Determine the maximum value of a subsequence in an integer array using state transition dynamic programming and bit oper…

困难
3290

最高乘法得分

The problem requires selecting four indices from an array to maximize a dynamic score with a transition approach.

中等
3291

形成目标字符串需要的最少字符串数 I

Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…

中等
3292

形成目标字符串需要的最少字符串数 II

Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…

困难
3302

字典序最小的合法序列

Determine the lexicographically smallest valid index sequence by using state transition dynamic programming over word1 a…

中等
3316

从原字符串里进行删除操作的最多次数

Determine the maximum number of characters you can remove from source while keeping pattern as a subsequence using array…

中等
3317

安排活动的方案数

Given n performers, x stages, and y scores, calculate the number of possible ways to assign performers and score bands.

困难
3320

统计能获胜的出招序列数

Count The Number of Winning Sequences is a dynamic programming challenge involving state transitions based on Alice’s cr…

困难
3332

旅客可以得到的最多点数

Calculate the maximum points a tourist can earn by choosing optimal city moves over k days using state transition DP.

中等
3333

找到初始输入字符串 II

Calculate how many potential original strings Alice might have intended to type, considering her clumsy typing behavior.

困难
3335

字符串转换后的长度 I

Calculate the total number of characters in a string after repeated transformations using dynamic programming and freque…

中等
3336

最大公约数相等的子序列数量

Count all pairs of non-empty subsequences in an integer array whose elements share the same greatest common divisor effi…

困难
3337

字符串转换后的长度 II

Calculate the length of a string after repeated transformations using state transition dynamic programming for large t v…

困难
3343

统计平衡排列的数目

Determine how many distinct permutations of a digit string are balanced using state transition dynamic programming effic…

困难
3351

好子序列的元素之和

Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.

困难
3352

统计小于 N 的 K 可约简整数

This problem challenges you to count the K-reducible numbers less than a given binary integer using dynamic programming.

困难
3363

最多可收集的水果数目

Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.

困难
3366

最小数组和

Solve the Minimum Array Sum problem using dynamic programming by tracking states and operations to minimize the sum of a…

中等
3367

移除边之后的权重最大和

Maximize the sum of edge weights in a tree after removals, using dynamic programming and tree traversal techniques.

困难
3376

破解锁的最少时间 I

Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…

中等
3388

统计数组中的美丽分割

Learn to count all valid beautiful splits in an array using state transition dynamic programming efficiently and accurat…

中等
3389

使字符频率相等的最少操作次数

This Hard problem asks to transform a string so all character frequencies match using minimal deletions, leveraging dyna…

困难
3393

统计异或值为给定值的路径数目

Count the number of paths in a grid where the XOR of all values along the path equals a given number.

中等
3409

最长相邻绝对差递减子序列

Find the length of the longest subsequence with non-increasing absolute adjacent differences.

中等
3410

删除所有值为某个元素后的最大子数组和

Maximize Subarray Sum After Removing All Occurrences of One Element involves finding the optimal subarray sum with one a…

困难
3414

不重叠区间的最大得分

Maximize the score of up to 4 non-overlapping intervals, considering their weight and ensuring no overlap between chosen…

困难
3418

机器人可以获得的最大金币数

Find the maximum amount of money a robot can collect while neutralizing robbers on its path in a grid.

中等
3428

最多 K 个元素的子序列的最值之和

Find the sum of the maximum and minimum elements of subsequences with at most k elements, using dynamic programming.

中等
3429

粉刷房子 IV

Solve the Paint House IV problem using state transition dynamic programming to minimize the painting costs while adherin…

中等
3434

子数组操作后的最大频率

Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…

中等
3441

变成好标题的最少代价

Solve Minimum Cost Good Caption with dynamic programming that builds minimum edit cost while enforcing character runs of…

困难
3444

使数组包含目标值倍数的最少增量

This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…

困难
3448

统计可以被最后一个数位整除的子字符串数目

Count the number of substrings in a string divisible by their last non-zero digit using dynamic programming.

困难
3458

选择 K 个互不重叠的特殊子字符串

Determine if k non-overlapping special substrings exist in a string using dynamic programming and careful substring trac…

中等
3459

最长 V 形对角线段的长度

Compute the maximum length of a V-shaped diagonal segment in a 2D integer matrix using state transition dynamic programm…

困难
3469

移除所有数组元素的最小代价

Find the minimum cost to remove all elements from the array with dynamic programming.

中等
3472

至多 K 次操作后的最长回文子序列

Find the longest palindromic subsequence of a string after performing at most k operations to adjust letters.

中等
3473

长度至少为 M 的 K 个子数组之和

Maximize the sum of k non-overlapping subarrays of at least length m using dynamic programming and prefix sums efficient…

中等
3490

统计美丽整数的数目

Count Beautiful Numbers using state transition dynamic programming to efficiently calculate valid numbers in a given ran…

困难
3500

将数组分割为子数组的最小代价

Optimize array splits with dynamic programming to minimize costs for the Minimum Cost to Divide Array Into Subarrays pro…

困难
3503

子字符串连接后的最长回文串 I

Compute the maximum palindrome length by concatenating substrings from two strings using state transition dynamic progra…

中等
3504

子字符串连接后的最长回文串 II

Compute the longest palindrome by concatenating substrings from two strings using state transition dynamic programming e…

困难
3505

使 K 个子数组内元素相等的最少操作数

Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…

困难
3509

最大化交错和为 K 的子序列乘积

Find the maximum product of a subsequence in an array with an alternating sum equal to a given target.

困难
3519

统计逐位非递减的整数

Count all integers between l and r whose digits never decrease in base b using state transition dynamic programming effi…

困难
3524

求出数组的 X 值 I

Determine the x-value of an array using state transition dynamic programming to count valid prefix-suffix operations eff…

中等
3530

有向无环图中合法拓扑排序的最大利润

Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…

困难
3533

判断连接可整除性

Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …

困难
3538

合并得到最小旅行时间

Minimize the total travel time by merging road signs, using dynamic programming to manage state transitions efficiently.

困难
3539

魔法序列的数组乘积之和

Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…

困难
3543

K 条边路径的最大边权和

Determine the maximum sum of edge weights for a k-edge path in a DAG using state transition dynamic programming efficien…

中等
3544

子树反转和

This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…

困难
3557

不相交子字符串的最大数量

Determine the maximum number of non-overlapping substrings in a word, each at least four characters and matching start-e…

中等
3559

给边赋权值的方案数 II

This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.

困难
3562

折扣价交易股票的最大利润

Solve the Maximum Profit from Trading Stocks with Discounts problem using binary-tree traversal and dynamic state tracki…

困难
3563

移除相邻字符后字典序最小的字符串

Find the lexicographically smallest string by repeatedly removing adjacent characters optimally using dynamic programmin…

困难
3573

买卖股票的最佳时机 V

Maximize profit from stock trades with at most k transactions using state transition dynamic programming for precise dec…

中等
3575

最大好子树分数

Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…

困难
3578

统计极差最大为 K 的分割方式数

Count the number of valid ways to partition an array into contiguous segments where max-min difference is at most k.

中等
3579

字符串转换需要的最小操作数

Transform word1 into word2 using minimal operations on substrings with a dynamic programming state transition approach.

困难
3585

树中找到带权中位节点

Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…

困难
3592

硬币面值还原

Recover coin denominations from a numWays array using state transition dynamic programming to reconstruct valid sets eff…

中等
3593

使叶子路径成本相等的最小增量

Find the minimum number of increments needed to equalize leaf path scores in a tree with different node costs.

中等
3594

所有人渡河所需的最短时间

Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.

困难
3599

划分数组得到最小 XOR

Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…

中等
3603

交替方向的最小路径代价 II

This problem focuses on finding the minimum cost path with alternating directions in a grid using dynamic programming.

中等
3615

图中的最长回文路径

Find the longest path in a graph that forms a palindrome using state transition dynamic programming and bitmask techniqu…

困难
3620

恢复网络路径

Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.

困难
3621

位计数深度为 K 的整数数目 I

Calculate the number of integers in a given range with a specific popcount-depth using state transition dynamic programm…

困难

关联高频模式

LeetCode 动态规划题型题解:529题训练路线