Hard 难度题单

679 道题目

这一层级用于训练对应强度下的解题稳定性与表达完整度,建议每轮固定复盘复杂度、边界和可替代方案。

训练重点

强调边界案例、优化推导与追问防守。

建议节奏

每轮 3-5 题,先口述思路再写代码,最后复盘错误路径。

搭配建议

结合模式页和题型页同步练,能更快形成可迁移能力。

4

寻找两个正序数组的中位数

Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.

困难
10

正则表达式匹配

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

困难
23

合并 K 个升序链表

Merge k Sorted Lists requires efficiently combining multiple sorted linked lists into one using pointers and priority qu…

困难
25

K 个一组翻转链表

Reverse Nodes in k-Group challenges you to reverse segments of a linked list in groups of size k.

困难
30

串联所有单词的子串

Find all starting indices of substrings in a string that are concatenations of a given list of words.

困难
32

最长有效括号

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

困难
37

解数独

Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.

困难
41

缺失的第一个正数

Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…

困难
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…

困难
51

N 皇后

Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…

困难
52

N 皇后 II

Solve the N-Queens II problem using backtracking with pruning to efficiently count all valid placements for n queens on …

困难
60

排列序列

Find the kth permutation sequence of a set of numbers using math and recursion to efficiently compute the result.

困难
65

有效数字

Determine if a given string represents a valid number using precise string parsing and character validation rules.

困难
68

文本左右对齐

Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.

困难
76

最小覆盖子串

Find the smallest substring of s containing all characters from t using a sliding window with running state updates for …

困难
84

柱状图中最大的矩形

Find the maximal rectangular area in a histogram using stack-based state management for precise bar tracking and width c…

困难
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…

困难
115

不同的子序列

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

困难
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…

困难
126

单词接龙 II

Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …

困难
127

单词接龙

Find the shortest transformation sequence from a start word to an end word, with each word in the sequence differing by …

困难
132

分割回文串 II

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

困难
135

分发糖果

The Candy problem is a greedy algorithm challenge where you need to minimize candy distribution while satisfying certain…

困难
140

单词拆分 II

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

困难
149

直线上最多的点数

Find the maximum number of points on a straight line in a 2D plane using array scanning and hash lookup.

困难
154

寻找旋转排序数组中的最小值 II

Find the minimum in a rotated sorted array with possible duplicates using binary search.

困难
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…

困难
212

单词搜索 II

Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.

困难
214

最短回文串

The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…

困难
218

天际线问题

The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …

困难
220

存在重复元素 III

The problem involves finding a pair of indices in an array where the index and value differences are within given limits…

困难
224

基本计算器

Implement a basic calculator to evaluate mathematical expressions, ensuring correct evaluation with stack-based manageme…

困难
233

数字 1 的个数

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

困难
239

滑动窗口最大值

Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…

困难
273

整数转换英文表示

Convert a given integer to its English words representation using mathematical logic and string manipulation.

困难
282

给表达式添加运算符

Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…

困难
295

数据流的中位数

Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.

困难
297

二叉树的序列化与反序列化

This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…

困难
301

删除无效的括号

Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…

困难
312

戳气球

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

困难
315

计算右侧小于当前元素的个数

Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.

困难
321

拼接最大数

Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.

困难
327

区间和的个数

Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…

困难
329

矩阵中的最长递增路径

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

困难
330

按要求补齐数组

Patching Array requires adding the minimum numbers to cover all sums from 1 to n using greedy choices and invariant chec…

困难
332

重新安排行程

Reconstruct Itinerary requires building a valid travel route using all tickets once, starting from JFK with lexical orde…

困难
335

路径交叉

Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.

困难
336

回文对

Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.

困难
352

将数据流变为多个不相交区间

The problem involves designing a class to summarize a data stream of non-negative integers as disjoint intervals using b…

困难
354

俄罗斯套娃信封问题

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

困难
363

矩形区域不超过 K 的最大数值和

Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…

困难
381

O(1) 时间插入、删除和获取随机元素 - 允许重复

This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…

困难
391

完美矩形

Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…

困难
403

青蛙过河

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

困难
407

接雨水 II

Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.

困难
410

分割数组的最大值

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

困难
420

强密码检验器

The Strong Password Checker problem challenges you to optimize password strength while minimizing steps using greedy alg…

困难
432

全 O(1) 的数据结构

Implement a data structure that tracks string counts and retrieves max or min keys efficiently in constant time.

困难
440

字典序的第K小数字

Find the k-th lexicographically smallest integer in a range using a Trie-based approach.

困难
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…

困难
460

LFU 缓存

Implement an LFU Cache using linked-list pointer manipulation with constant-time get and put operations for interview sc…

困难
466

统计重复个数

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

困难
472

连接词

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

困难
479

最大回文数乘积

Find the largest palindromic number from the product of two n-digit integers using math and enumeration efficiently.

困难
480

滑动窗口中位数

Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…

困难
483

最小好进制

Find the smallest good base of an integer n using binary search over the valid answer space.

困难
488

祖玛游戏

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

困难
493

翻转对

Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.

困难
502

IPO

Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…

困难
514

自由之路

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

困难
517

超级洗衣机

Calculate the minimum moves to balance dresses across washing machines using a greedy strategy and invariant validation …

困难
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 …

困难
564

寻找最近的回文数

Identify the nearest palindrome to a given integer string, handling ties and large numbers efficiently using math and st…

困难
587

安装栅栏

Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.

困难
591

标签验证器

The Tag Validator problem involves validating a code snippet by parsing through tags using a stack-based state managemen…

困难
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.

困难
630

课程表 III

Solve the 'Course Schedule III' problem with a greedy approach involving course selection and validation of constraints.

困难
632

最小区间

Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…

困难
639

解码方法 II

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

困难
664

奇怪的打印机

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

困难
668

乘法表中第k小的数

Find the kth smallest number in an m x n multiplication table using binary search over the valid answer space.

困难
675

为高尔夫比赛砍树

Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…

困难
679

24 点游戏

Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…

困难
685

冗余连接 II

Find and remove the redundant connection in a directed graph that was originally a rooted tree.

困难
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…

困难
699

掉落的方块

Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…

困难
710

黑名单中的随机数

Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…

困难
715

Range 模块

Design a RangeModule to track and query half-open intervals using segment trees or ordered sets.

困难
719

找出第 K 小的数对距离

Solve Find K-th Smallest Pair Distance by sorting nums, then binary searching the distance and counting valid pairs with…

困难
726

原子的数量

Compute the exact count of each atom in a chemical formula using stack-based state management and hashing techniques eff…

困难
730

统计不同回文子序列

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

困难
732

我的日程安排表 III

Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…

困难
736

Lisp 语法解析

Parse Lisp expressions using stack-based state management to evaluate variables and operations.

困难
741

摘樱桃

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

困难
745

前缀和后缀搜索

Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.

困难
749

隔离病毒

Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…

困难
753

破解保险箱

The Cracking the Safe problem involves finding the shortest password sequence to unlock a safe using graph traversal and…

困难
757

设置交集大小至少为2

Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.

困难
761

特殊的二进制字符串

Solve the Special Binary String problem using string manipulation and recursion, optimizing lexicographical order.

困难
765

情侣牵手

This problem requires arranging couples sitting apart in a row with the minimum number of swaps using graph traversal an…

困难
768

最多能完成排序的块 II

Determine the maximum number of chunks you can split an array into so that sorting each chunk results in a fully sorted …

困难
770

基本计算器 IV

Simplify mathematical expressions using stack-based state management, handling variables, operators, and polynomial term…

困难
773

滑动谜题

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

困难
778

水位上升的泳池中游泳

Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.

困难
780

到达终点

Determine whether it is possible to reach a target point from a start point using repeated additive moves following stri…

困难
782

变为棋盘

Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.

困难
793

阶乘函数后 K 个零

Solve for the number of integers whose factorial ends with a specific number of zeroes using binary search techniques.

困难
798

得分最高的最小轮调

Find the smallest rotation index with the highest score using array and prefix sum techniques.

困难
801

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

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

困难
803

打砖块

Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.

困难
805

数组的均值分割

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

困难
810

黑板异或游戏

The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…

困难
815

公交路线

Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.

困难
818

赛车

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

困难
827

最大人工岛

Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…

困难
828

统计子串中的唯一字符

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

困难
829

连续整数求和

Find the number of ways to express a number as the sum of consecutive positive integers.

困难
834

树中距离之和

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

困难
839

相似字符串组

Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…

困难
843

猜猜这个单词

Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…

困难
847

访问所有节点的最短路径

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

困难
850

矩形面积 II

The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.

困难
854

相似度为 K 的字符串

K-Similar Strings involves finding the minimal number of swaps to transform one string into another through character sw…

困难
857

雇佣 K 名工人的最低成本

Find the minimum cost to hire exactly k workers based on quality and wage expectations in this challenging greedy proble…

困难
862

和至少为 K 的最短子数组

Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.

困难
864

获取所有钥匙的最短路径

Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.

困难
871

最低加油次数

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

困难
878

第 N 个神奇数字

Find the nth magical number divisible by a or b, using binary search to efficiently handle large inputs.

困难
879

盈利计划

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

困难
882

细分图中的可到达节点

The Reachable Nodes In Subdivided Graph problem requires efficiently finding the reachable nodes using graph traversal a…

困难
887

鸡蛋掉落

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

困难
891

子序列宽度之和

Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.

困难
895

最大频率栈

Design a stack-like data structure to manage elements and handle frequent stack operations, including popping the most f…

困难
899

有序队列

Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…

困难
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…

困难
906

超级回文数

Count all super-palindromes in a given numeric range, where each is a palindrome and square of a palindrome.

困难
913

猫和老鼠

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

困难
920

播放列表的数量

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

困难
924

尽量减少恶意软件的传播

Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.

困难
927

三等分

Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…

困难
928

尽量减少恶意软件的传播 II

Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.

困难
936

戳印序列

Solve Stamping The Sequence with stack-based state management to convert string s to target using stamp efficiently.

困难
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…

困难
952

按公因数计算最大组件大小

Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …

困难
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…

困难
972

相等的有理数

Given two rational numbers as strings with possible repeating decimals, determine if they represent the same number.

困难
975

奇偶跳

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

困难
980

不同路径 III

Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…

困难
982

按位与为零的三元组

Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…

困难
987

二叉树的垂序遍历

Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.

困难
992

K 个不同整数的子数组

Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.

困难
995

K 连续位的最小翻转次数

Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…

困难
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.

困难
1001

网格照明

Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …

困难
1012

至少有 1 位重复的数字

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

困难
1028

从先序遍历还原二叉树

Recover a binary tree from its preorder traversal string by tracking node depth and reconstructing child relationships e…

困难
1032

字符流

Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…

困难
1036

逃离大迷宫

The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…

困难
1044

最长重复子串

Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.

困难
1074

元素和为目标值的子矩阵数量

Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…

困难
1092

最短公共超序列

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

困难
1095

山脉数组中查找目标值

Find in Mountain Array requires locating a target using binary search over a peak-structured array efficiently in intera…

困难
1096

花括号展开 II

Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…

困难
1106

解析布尔表达式

Solve the "Parsing A Boolean Expression" problem by evaluating boolean expressions using stack-based state management, r…

困难
1125

最小的必要团队

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

困难
1147

段式回文

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

困难
1157

子数组中占绝大多数的元素

Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.

困难
1163

按字典序排在最后的子串

Identify the lexicographically last substring in a string using two-pointer scanning with invariant tracking efficiently…

困难
1172

餐盘栈

Design a system that manages dinner plate stacks using stack-based state management, handling dynamic plate placement an…

困难
1178

猜字谜

Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…

困难
1187

使数组严格递增

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

困难
1192

查找集群内的关键连接

Find critical connections in a network of servers, ensuring efficient traversal using depth-first search and Tarjan's al…

困难
1203

项目管理

Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…

困难
1206

设计跳表

Implement a Skiplist efficiently using linked-list pointer manipulation to support search, add, and erase operations in …

困难
1210

穿过迷宫的最少移动次数

Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.

困难
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…

困难
1224

最大相等频率

Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…

困难
1235

规划兼职工作

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

困难
1240

铺瓷砖

Tiling a Rectangle with the Fewest Squares problem asks for the minimum number of squares required to cover a rectangle …

困难
1250

检查「好数组」

Determine if a given array of positive integers can generate 1 using integer multiples of any subset, leveraging number …

困难
1255

得分最高的单词集合

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

困难
1263

推箱子

Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…

困难
1269

停在原地的方案数

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

困难
1278

分割回文串 III

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

困难
1284

转化为全零矩阵的最少反转次数

Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…

困难
1289

下降路径最小和 II

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

困难
1293

网格中的最短路径

Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.

困难
1298

你能从盒子里获得的最大糖果数

Collect maximum candies from boxes by exploring initially available boxes and using keys to unlock additional ones effic…

困难
1301

最大得分的路径数目

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

困难
1307

口算难题

Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.

困难
1312

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

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

困难
1316

不同的循环子字符串

Count the distinct non-empty substrings of a given string that can be formed as the concatenation of a string with itsel…

困难
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…

困难
1330

翻转子数组得到最大的数组值

Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.

困难
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.

困难
1345

跳跃游戏 IV

Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…

困难
1349

参加考试的最大学生数

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

困难
1354

多次求和构造目标数组

This problem requires constructing a target array from an array of ones, using multiple sum operations and a priority qu…

困难
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…

困难
1368

使网格图至少有一条有效路径的最小代价

Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.

困难
1373

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

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

困难
1377

T 秒后青蛙的位置

The problem asks for the probability that a frog reaches a target vertex after t seconds in a tree graph.

困难
1383

最大的团队表现值

Maximize the performance of a team by selecting up to k engineers with the highest performance based on speed and effici…

困难
1388

3n 块披萨

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

困难
1392

最长快乐前缀

Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.

困难
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…

困难
1439

有序矩阵中的第 k 个最小数组和

Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.

困难
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 …

困难
1453

圆形靶内的最大飞镖数量

Maximize the number of darts on a circular dartboard given dart positions and radius.

困难
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…

困难
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.

困难
1489

找到最小生成树里的关键边和伪关键边

Identify critical and pseudo-critical edges in a weighted graph's minimum spanning tree using Union Find efficiently.

困难
1494

并行课程 II

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

困难
1499

满足不等式的最大值

Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…

困难
1505

最多 K 次交换相邻数位后得到的最小整数

Reorder digits using at most k adjacent swaps to produce the smallest possible integer, leveraging greedy selection effi…

困难
1510

石子游戏 IV

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

困难
1515

服务中心的最佳位置

Find the optimal service center position in a city by minimizing the sum of Euclidean distances to all customers.

困难
1520

最多的不重叠子字符串

Find the maximum number of non-overlapping substrings in a given string, ensuring no two substrings intersect unless one…

困难
1521

找到最接近目标值的函数值

In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.

困难
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 …

困难
1542

找出最长的超赞子字符串

Find the maximum-length awesome substring in a numeric string using hash table and bit manipulation for palindrome poten…

困难
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…

困难
1568

使陆地分离的最少天数

Find the minimum number of days to disconnect an island in a grid using depth-first search.

困难
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…

困难
1579

保证图可完全遍历

Maximize the number of edges that can be removed while keeping the graph fully traversable for both Alice and Bob.

困难
1585

检查字符串是否可以通过排序子字符串得到另一个字符串

This problem requires checking if string 's' can be transformed into string 't' using substring sort operations.

困难
1591

奇怪的打印机 II

Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…

困难
1595

连通两组点的最小成本

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

困难
1601

最多可达成的换楼请求数目

Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.

困难
1606

找到处理最多请求的服务器

Given k servers and a series of requests, find the busiest server(s) using greedy strategies and efficient server tracki…

困难
1610

可见点的最大数目

Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…

困难
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…

困难
1622

奇妙序列

Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…

困难
1627

带阈值的图连通性

In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…

困难
1632

矩阵转换后的排名

Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…

困难
1639

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

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

困难
1643

第 K 条最小指令

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

困难
1649

通过指令创建有序数组

The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.

困难
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…

困难
1665

完成所有任务的最少初始能量

Determine the minimum initial energy needed to finish all tasks using a greedy ordering based on required versus actual …

困难
1671

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

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

困难
1675

数组的最小偏移量

Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…

困难
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…

困难
1691

堆叠长方体的最大高度

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

困难
1697

检查边长度限制的路径是否存在

Solve the problem of checking if there exists a path between two nodes under edge length constraints using efficient tec…

困难
1703

得到连续 K 个 1 的最少相邻交换次数

Find the minimum number of adjacent swaps to gather k consecutive ones in a binary array using sliding window logic.

困难
1707

与数组中元素的最大异或值

Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…

困难
1713

得到子序列的最少操作次数

Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…

困难
1719

重构一棵树的方案数

Determine how many distinct rooted trees can be reconstructed from given node pairs using careful traversal and state tr…

困难
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…

困难
1739

放置盒子

Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.

困难
1745

分割回文串 IV

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

困难
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…

困难
1761

一个图中连通三元组的最小度数

Find the minimum degree of a connected trio in a graph using enumeration over nodes and edges.

困难
1766

互质树

Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…

困难
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…

困难
1776

车队 II

Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…

困难
1782

统计点对的数目

Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.

困难
1787

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

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

困难
1793

好子数组的最大分数

Maximize the score of a good subarray using binary search to explore the valid answer space with a focus on two-pointer …

困难
1799

N 次操作后的最大分数和

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

困难
1803

统计异或值在范围内的数对有多少

Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …

困难
1808

好因子的最大数目

Solve Maximize Number of Nice Divisors by splitting primeFactors into mostly 3s and using fast modular exponentiation.

困难
1815

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

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

困难
1819

序列中不同最大公约数的数目

Given an array of positive integers, find the number of different subsequences' GCDs.

困难
1825

求出 MK 平均值

Find the MKAverage of a stream of integers using a queue-driven approach with efficient state management.

困难
1830

使字符串有序的最少操作次数

Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…

困难
1835

所有数对按位与结果的异或和

Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.

困难
1840

最高建筑高度

Find the maximum building height in a city given height restrictions for specific buildings.

困难
1847

最近的房间

Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…

困难
1851

包含每个查询的最小区间

Find the smallest interval containing each query efficiently using binary search.

困难
1857

有向图中最大颜色值

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

困难
1862

向下取整数对和

The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…

困难
1866

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

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

困难
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…

困难
1889

装包裹的最小浪费空间

Minimize the wasted space when packaging items into boxes, considering package and box size constraints.

困难
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…

困难
1912

设计电影租借系统

Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.

困难
1916

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

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

困难
1923

最长公共子路径

The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…

困难
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.

困难
1932

合并多棵二叉搜索树

This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.

困难
1938

查询最大基因差

Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.

困难
1944

队列中可以看到的人数

Compute how many people each person in a queue can see to their right using efficient stack-based state management.

困难
1948

删除系统中的重复文件夹

Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…

困难
1955

统计特殊子序列的数目

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

困难
1960

两个回文子字符串长度的最大乘积

Find the maximum product of lengths of two non-overlapping odd-length palindromic substrings using string and rolling ha…

困难
1964

找出到每个位置为止最长的有效障碍赛跑路线

Compute the longest valid obstacle course at each position using binary search and careful array tracking techniques eff…

困难
1970

你能穿过矩阵的最后一天

Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.

困难
1977

划分数字的方案数

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

困难
1982

从子集的和还原数组

Reconstruct an array from given subset sums using divide and conquer approach and leveraging array properties.

困难
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.

困难
1998

数组的最大公因数排序

The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.

困难
2003

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

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

困难
2009

使数组连续的最少操作数

Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…

困难
2014

重复 K 次的最长子序列

Find the longest subsequence repeated k times in a string using backtracking search with pruning.

困难
2019

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

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

困难
2025

分割数组的最多方案数

Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…

困难
2030

含特定字母的最小子序列

Find the lexicographically smallest subsequence of length k with at least repetition occurrences of a given letter using…

困难
2035

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

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

困难
2040

两个有序数组的第 K 小乘积

Find the kth smallest product from two sorted arrays using binary search across possible product values efficiently.

困难
2045

到达目的地的第二短时间

Find the second minimum time to reach a destination using BFS while accounting for traffic signal delays in a graph trav…

困难
2050

并行课程 III

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

困难
2056

棋盘上有效移动组合的数目

Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…

困难
2060

同源字符串检测

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

困难
2065

最大化一张图中的路径价值

Calculate the maximum path quality in a graph using backtracking and pruning to optimize node visits within time limits …

困难
2071

你可以安排的最多任务数目

Maximize the number of tasks that can be completed by efficiently using workers and magical pills.

困难
2076

处理含限制条件的好友请求

Determine which friend requests can be accepted without violating direct or indirect restrictions using union-find logic…

困难
2081

k 镜像数字的和

This problem requires finding the sum of the n smallest k-mirror numbers by generating palindromes in base-k and base-10…

困难
2088

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

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

困难
2092

找出知晓秘密的所有专家

Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…

困难
2097

合法重新排列数对

Given pairs of numbers, find a valid arrangement where each pair follows a specific condition.

困难
2102

序列顺序查询

Track rankings of locations with names and scores, adding new locations and retrieving top-ranked ones efficiently.

困难
2106

摘水果

Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.

困难
2111

使数组 K 递增的最少操作次数

This problem requires finding the minimum number of operations to make an array K-increasing using binary search over th…

困难
2117

一个区间内所有数乘积的缩写

Calculate the abbreviated product of integers in a range efficiently using math-driven analysis of trailing zeros and si…

困难
2122

还原原数组

Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…

困难
2127

参加会议的最多员工数

Determine the maximum employees to invite based on favorite adjacency constraints using graph indegree and topological o…

困难
2132

用邮票贴满网格图

Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…

困难
2136

全部开花的最早一天

Find the earliest day where all flower seeds are blooming based on their planting and growth times, using a greedy strat…

困难
2141

同时运行 N 台电脑的最长时间

Solve the problem of determining the maximum running time of n computers using a set of batteries.

困难
2147

分隔长廊的方案数

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

困难
2151

基于陈述统计最多好人数

Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.

困难
2156

查找给定哈希值的子串

Locate the first substring of length k whose rolling hash matches the given hashValue using a sliding window approach.

困难
2157

字符串分组

Group words into connected sets using operations on characters with string and bit manipulation techniques.

困难
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.

困难
2179

统计数组中好三元组数目

Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.

困难
2183

统计可以被 K 整除的下标对数目

Count Array Pairs Divisible by K requires counting index pairs whose products are divisible by a given number k.

困难
2188

完成比赛的最少时间

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

困难
2193

得到回文串的最少操作次数

The problem challenges you to find the minimum number of adjacent swaps to make a string a palindrome.

困难
2197

替换数组中的非互质数

Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…

困难
2203

包含要求路径的最小带权子图

Find the minimum weighted subgraph that connects three specified nodes in a directed graph with constraints.

困难
2209

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

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

困难
2213

由单个字符重复的最长子字符串

Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…

困难
2218

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

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

困难
2223

构造字符串的总得分和

Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…

困难
2227

加密解密字符串

The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …

困难
2234

花园的最大总美丽值

Determine the maximum total beauty of gardens by strategically planting flowers using binary search over achievable flow…

困难
2242

节点序列的最大得分

Find the maximum score of a valid node sequence in an undirected graph with given node scores and edges.

困难
2246

相邻字符不同的最长路径

Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…

困难
2251

花期内花的数目

Find the number of flowers in full bloom at the given times for a list of people.

困难
2258

逃离火灾

Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…

困难
2262

字符串的总引力

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

困难
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.

困难
2276

统计区间中的整数数目

Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…

困难
2281

巫师的总力量和

The Sum of Total Strength of Wizards problem asks for the sum of the total strengths of all contiguous subarrays of wiza…

困难
2286

以组为单位订音乐会的门票

Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.

困难
2290

到达角落需要移除障碍物的最小数目

Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.

困难
2296

设计一个文本编辑器

Design a text editor that supports text manipulation and cursor navigation operations efficiently with linked-list-based…

困难
2301

替换字符后匹配

Determine if a target substring can appear in a string after optional character replacements using given mappings effici…

困难
2302

统计得分小于 K 的子数组数目

Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…

困难
2306

公司命名

The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…

困难
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.

困难
2321

拼接数组的最大分数

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

困难
2322

从树中删除边的最小分数

Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.

困难
2328

网格图中递增路径的数目

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

困难
2334

元素值大于变化阈值的子数组

Find the size of a subarray with all elements greater than threshold divided by length using stack-based state managemen…

困难
2338

统计理想数组的数目

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

困难
2344

使数组可以被整除的最少删除次数

Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.

困难
2350

不可能得到的最短骰子序列

Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…

困难
2354

优质数对的数目

Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…

困难
2360

图中的最长环

The problem asks to find the longest cycle in a directed graph with specific edge constraints.

困难
2366

将数组排序的最少替换次数

Minimize the number of operations to make the array sorted in non-decreasing order by replacing elements with sums of tw…

困难
2376

统计特殊整数

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

困难
2382

删除操作后的最大子段和

Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…

困难
2386

找出数组的第 K 大和

Find the K-Sum of an Array requires computing the kth largest subsequence sum in an array using sorting and heap techniq…

困难
2392

给定条件下构造矩阵

Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…

困难
2398

预算内的最多机器人数目

Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…

困难
2402

会议室 III

Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.

困难
2407

最长递增子序列 II

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

困难
2412

完成所有交易的初始最少钱数

Find the minimum money required to complete all transactions in any order while considering cost and cashback.

困难
2416

字符串的前缀分数和

The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …

困难
2421

好路径的数目

Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.

困难
2426

满足不等式的数对数目

Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.

困难
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…

困难
2440

创建价值相同的连通块

Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.

困难
2444

统计定界子数组的数目

Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.

困难
2448

使数组相等的最小开销

Find the minimum cost to make all elements of an array equal by using binary search over valid answers.

困难
2449

使数组相似的最少操作次数

Determine the minimum operations to make two arrays similar by adjusting pairs while respecting element frequencies and …

困难
2454

下一个更大元素 IV

Find the second greater integer for each element in an array using binary search and monotonic stack techniques.

困难
2458

移除子树后的二叉树高度

Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…

困难
2463

最小移动总距离

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

困难
2468

根据限制分割消息

Split Message Based on Limit requires dividing a string into parts with length constraints using a calculated suffix pat…

困难
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.

困难
2488

统计中位数为 K 的子数组

Count the number of subarrays in a given array with median equal to a specified value k.

困难
2493

将节点分成尽可能多的组

Determine the maximum number of groups nodes can form in a graph using depth-first traversal without violating edge conn…

困难
2499

让数组不相等的最小总代价

Calculate the minimum cost to rearrange nums1 so that no element matches nums2 using optimal swaps and hash counting.

困难
2503

矩阵查询可获得的最大分数

Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.

困难
2508

添加边使所有节点度数都为偶数

Determine if it's possible to add at most two edges to make all node degrees even in an undirected graph.

困难
2509

查询树中环的长度

Solve the problem of determining cycle lengths in a binary tree with added edges through queries.

困难
2514

统计同位异构字符串数目

Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.

困难
2518

好分区的数目

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

困难
2528

最大化城市的最小电量

Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…

困难
2532

过桥的时间

Time to Cross a Bridge involves simulating worker movements using arrays and heaps to determine when the last worker cro…

困难
2538

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

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

困难
2543

判断一个点是否可以到达

Determine if a target point is reachable from (1,1) using math-based moves following number theory rules efficiently.

困难
2547

拆分数组的最小代价

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

困难
2551

将珠子放入背包中

The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…

困难
2552

统计上升四元组

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

困难
2561

重排水果

Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…

困难
2565

最少得分子序列

Find the minimum score of a string by removing characters from t while maintaining subsequence validity with s.

困难
2569

更新数组后处理求和查询

Solve the Handling Sum Queries After Update problem using arrays and segment trees with lazy propagation for efficiency.

困难
2573

找出对应 LCP 矩阵的字符串

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

困难
2577

在网格图中访问一个格子的最少时间

Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…

困难
2581

统计可能的树根数目

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

困难
2584

分割数组使乘积互质

Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…

困难
2585

获得分数的方法数

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

困难
2589

完成所有任务的最少时间

Determine the minimum active time for a computer to complete all scheduled tasks within their specific time windows effi…

困难
2603

收集树中金币

The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…

困难
2608

图中的最短环

Find the shortest cycle in a bi-directional graph using BFS for optimal traversal.

困难
2612

最少翻转操作数

Find the minimum number of operations to move a 1 in an array from a given start position to other positions, considerin…

困难
2617

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

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

困难
2630

记忆函数 II

Implementing a memoized function ensures that identical inputs avoid redundant calls, boosting efficiency and performanc…

困难
2642

设计可以求最短路径的图类

Implement a dynamic weighted directed graph with efficient shortest path queries and edge additions in real time.

困难
2646

最小化旅行的价格总和

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

困难
2650

设计可取消函数

Master designing cancellable functions with generators, handling promise flow, cancellation, and error propagation effec…

困难
2659

将数组清空

Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.

困难
2663

字典序最小的美丽字符串

Find the lexicographically smallest beautiful string larger than the given string using greedy choice and invariant vali…

困难
2681

英雄的力量

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

困难
2699

修改图中的边权

Modify Graph Edge Weights is a graph problem where you adjust edge weights to match a target shortest path distance.

困难
2709

最大公约数遍历

Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.

困难
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…

困难
2732

找到矩阵中的好子集

Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…

困难
2736

最大和查询

Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…

困难
2742

给墙壁刷油漆

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

困难
2751

机器人碰撞

Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.

困难
2763

所有子数组中不平衡数字之和

Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.

困难
2781

最长合法子字符串的长度

This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.

困难
2790

长度递增组的最大数目

Maximize the number of groups that can be formed with given usage limits, leveraging binary search for optimal solutions…

困难
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…

困难
2813

子序列最大优雅度

Maximize elegance of a k-length subsequence from a list of items with profits and categories.

困难
2818

操作使得分最大

Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.

困难
2827

范围中美丽整数的数目

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

困难
2835

使子序列的和等于目标的最少操作次数

The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …

困难
2836

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

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

困难
2842

统计一个字符串的 k 子序列美丽值最大的数目

Determine the number of k-length unique subsequences in a string that maximize the sum of character frequencies efficien…

困难
2846

边权重均等查询

Find the minimum number of operations to equalize edge weights in a tree between given pairs of nodes.

困难
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…

困难
2862

完全子集的最大元素和

Given a 1-indexed array, select a subset where indices' product is a perfect square, then return the maximum sum.

困难
2867

统计树中的合法路径数目

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

困难
2872

可以被 K 整除连通块的最大数目

Determine the maximum number of connected components in a tree where each component sum is divisible by k using DFS.

困难
2876

有向图访问计数

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

困难
2897

对数组执行操作使平方和最大

Maximizing the sum of squares in an array through bitwise operations on selected elements.

困难
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…

困难
2916

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

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

困难
2920

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

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

困难
2926

平衡子序列的最大和

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

困难
2931

购买物品的最大开销

Maximize spending by carefully choosing the right items across multiple shops over m * n days.

困难
2935

找出强数对的最大异或值 II

Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.

困难
2940

找到 Alice 和 Bob 可以相遇的建筑

Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.

困难
2945

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

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

困难
2949

统计美丽子字符串 II

Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.

困难
2953

统计完全子字符串

Count Complete Substrings involves finding substrings where each character appears exactly k times with constraints on a…

困难
2954

统计感冒序列的数目

Calculate all valid infection sequences in a line by using array positions and combinatorial math efficiently for n peop…

困难
2959

关闭分部的可行集合数目

Calculate all valid sets of branch closures while keeping remaining branches within maxDistance using bitmask and graph …

困难
2963

统计好分割方案的数目

Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…

困难
2968

执行操作使频率分数最大

Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…

困难
2972

统计移除递增子数组的数目 II

Count the number of incremovable subarrays where removal of the subarray results in a strictly increasing array.

困难
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…

困难
2983

回文串重新排列查询

Given a string and queries, check if rearranging specified substrings can make the string a palindrome.

困难
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 …

困难
3008

找出数组中的美丽下标 II

Find Beautiful Indices in the Given Array II challenges you to use binary search and string matching techniques.

困难
3013

将数组分成最小总代价的子数组 II

This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.

困难
3017

按距离统计房屋对数目 II

Count the Number of Houses at a Certain Distance II is a graph problem that requires efficient pair counting with an add…

困难
3022

给定操作次数内使剩余元素的或值最小

Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.

困难
3027

人员站位的方案数 II

Calculate all valid placements of people on a 2D grid ensuring Alice can fence herself with Bob without enclosing others…

困难
3031

将单词恢复初始状态所需的最短时间 II

The problem asks to calculate the minimum time required to revert a string to its initial state using specific operation…

困难
3036

匹配模式数组的子数组数目 II

Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.

困难
3041

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

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

困难
3045

统计前后缀下标对 II

Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …

困难
3049

标记所有下标的最早秒数 II

This problem asks to determine the earliest second at which all indices in an array can be marked using a sequence of op…

困难
3068

最大节点价值之和

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

困难
3072

将元素分配到两个数组中 II

Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…

困难
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.

困难
3086

拾起 K 个 1 需要的最少行动次数

Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.

困难
3093

最长公共后缀查询

Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…

困难
3098

求出所有子序列的能量和

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

困难
3102

最小化曼哈顿距离

Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.

困难
3108

带权图里旅途的最小代价

Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…

困难
3113

边界元素是最大值的子数组数目

Count the subarrays where the first and last elements are the largest in the subarray, utilizing binary search over vali…

困难
3116

单面值组合的第 K 小金额

Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…

困难
3117

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

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

困难
3123

最短路径中的边

Use two Dijkstra runs to mark exactly which edges can appear on at least one shortest path from 0 to n - 1.

困难
3130

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

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

困难
3134

找出唯一性数组的中位数

Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…

困难
3139

使数组中所有元素相等的最小开销

Compute the minimum cost to make all elements equal using selective operations guided by greedy choices and invariant ch…

困难
3145

大数组元素的乘积

Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…

困难
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…

困难
3161

物块放置查询

Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…

困难
3165

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

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

困难
3171

找到按位或最接近 K 的子数组

Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.

困难
3177

求出最长好子序列 II

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

困难
3181

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

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

困难
3187

数组中的峰值

Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…

困难
3193

统计逆序对的数目

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

困难
3197

包含所有 1 的最小矩形面积 II

Find the minimum area to cover all 1's in a 2D binary grid using three non-overlapping rectangles.

困难
3203

合并两棵树后的最小直径

Calculate the minimum diameter after merging two trees by strategically connecting nodes to minimize the longest path in…

困难
3209

子数组按位与值为 K 的数目

The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…

困难
3213

最小代价构造字符串

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

困难
3219

切蛋糕的最小总开销 II

Solve Minimum Cost for Cutting Cake II by choosing optimal cuts using a greedy strategy while tracking cost increments p…

困难
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…

困难
3235

判断矩形的两个角落是否可达

Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.

困难
3241

标记所有节点需要的时间

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

困难
3244

新增道路查询后的最短距离 II

The problem involves calculating the shortest path from city 0 to city n-1 after each road addition, leveraging greedy c…

困难
3245

交替组 III

Solve Alternating Groups III using array manipulation and a binary indexed tree to track maximal alternating sequences e…

困难
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.

困难
3260

找出最大的 N 位 K 回文数

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

困难
3261

统计满足 K 约束的子字符串数量 II

Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…

困难
3266

K 次乘运算后的最终数组 II

Optimize the final state of an array after performing k multiplication operations with priority queues.

困难
3267

统计近似相等数对 II

Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.

困难
3272

统计好整数的数目

Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.

困难
3273

对 Bob 造成的最少伤害

Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.

困难
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…

困难
3283

吃掉所有兵需要的最多移动次数

Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…

困难
3287

求出数组中最大序列值

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

困难
3288

最长上升路径的长度

Determine the maximum length of an increasing path in a 2D array using binary search over potential path lengths efficie…

困难
3292

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

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

困难
3298

统计重新排列后包含另一个字符串的子字符串数目 II

Count Substrings That Can Be Rearranged to Contain a String II involves identifying valid substrings with a sliding wind…

困难
3303

第一个几乎相等子字符串的下标

Locate the first substring in s that is almost equal to pattern by allowing at most one character mismatch efficiently.

困难
3307

找出第 K 个字符 II

Find the K-th character in a string game using bit manipulation and recursion, optimizing performance for large k values…

困难
3311

构造符合图结构的二维矩阵

This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.

困难
3312

查询排序后的最大公约数

Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…

困难
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…

困难
3321

计算子数组的 x-sum II

Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.

困难
3327

判断 DFS 字符串是否是回文串

Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…

困难
3333

找到初始输入字符串 II

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

困难
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…

困难
3347

执行操作后元素的最高频率 II

Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…

困难
3348

最小可整除数位乘积 II

Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…

困难
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.

困难
3357

最小化相邻元素的最大差值

Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.

困难
3363

最多可收集的水果数目

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

困难
3367

移除边之后的权重最大和

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

困难
3373

连接两棵树后最大目标节点数目 II

Maximize the number of target nodes after connecting two trees by analyzing their structure and target relationships.

困难
3378

统计最小公倍数图中的连通块数目

Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…

困难
3382

用点构造面积最大的矩形 II

Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…

困难
3389

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

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

困难
3395

唯一中间众数子序列 I

Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.

困难
3398

字符相同的最短子字符串 I

Minimize the length of the longest substring with identical characters after at most numOps changes in a binary string.

困难
3399

字符相同的最短子字符串 II

Find the minimal length of a substring with identical characters using binary search and controlled character flips effi…

困难
3405

统计恰好有 K 个相等相邻元素的数组数目

Count the number of valid arrays with exactly k adjacent elements that are equal, using math and combinatorics technique…

困难
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…

困难
3420

统计 K 次操作以内得到非递减子数组的数目

This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.

困难
3425

最长特殊路径

Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.

困难
3426

所有安放棋子方案的曼哈顿距离

This problem challenges you to calculate Manhattan distances in all valid arrangements of identical pieces on a grid.

困难
3430

最多 K 个元素的子数组的最值之和

Compute the sum of maximum and minimum values in all subarrays up to size k using efficient stack-based state management…

困难
3435

最短公共超序列的字母出现频率

Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …

困难
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…

困难
3445

奇偶频次间的最大差值 II

Find the maximum difference between even and odd character frequencies in substrings using sliding window updates effici…

困难
3448

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

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

困难
3449

最大化游戏分数的最小值

Maximizing the minimum score after at most m moves, leveraging binary search and greedy strategies over an array of scor…

困难
3454

分割正方形 II

Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …

困难
3455

最短匹配子字符串

Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…

困难
3459

最长 V 形对角线段的长度

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

困难
3463

判断操作后字符串中的数字是否相等 II

Determine if repeated digit-sum operations on a numeric string reduce it to two equal digits using math and string techn…

困难
3464

正方形上的点之间的最大距离

Select k points on a square boundary to maximize minimum Manhattan distance using binary search and greedy placement str…

困难
3470

全排列 IV

Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…

困难
3474

字典序最小的生成字符串

Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.

困难
3480

删除一个冲突对后最大子数组数目

Maximize the count of subarrays after removing one conflicting pair using array traversal and segment tree logic efficie…

困难
3485

删除元素后 K 个字符串的最长公共前缀

Find the longest common prefix length of k strings after removing an element in the array.

困难
3486

最长特殊路径 II

Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…

困难
3490

统计美丽整数的数目

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

困难
3495

使数组元素都变为零的最少操作次数

Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…

困难
3500

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

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

困难
3501

操作后最大活跃区段数 II

Maximize the number of active sections in a binary string with at most one trade.

困难
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.

困难
3510

移除最小数对使数组有序 II

The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.

困难
3515

带权树中的最短路径

Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.

困难
3518

最小回文排列 II

Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.

困难
3519

统计逐位非递减的整数

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

困难
3525

求出数组的 X 值 II

The "Find X Value of Array II" problem requires calculating the number of ways to remove a suffix from an array such tha…

困难
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 …

困难
3534

针对图的路径存在性查询 II

Solve path existence queries in a graph using binary search on the answer space, focusing on sorted nodes and maximum di…

困难
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…

困难
3544

子树反转和

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

困难
3547

图中边值的最大和

Maximize the sum of edge values in a connected graph by assigning unique node values and optimizing edge products.

困难
3548

等和矩阵分割 II

Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.

困难
3553

包含要求路径的最小带权子图 II

Solve the Minimum Weighted Subgraph With the Required Paths II problem by leveraging binary-tree traversal and efficient…

困难
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…

困难
3569

分割数组后不同质数的最大数目

Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…

困难
3574

最大子数组 GCD 分数

Maximize Subarray GCD Score focuses on maximizing a subarray's score by using at most k doubling operations on an array …

困难
3575

最大好子树分数

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

困难
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…

困难
3590

第 K 小的路径异或和

This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…

困难
3594

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

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

困难
3600

升级后最大生成树稳定性

Maximizing the stability of a spanning tree with upgrades requires careful optimization of edge strengths using binary s…

困难
3605

数组的最小稳定性因子

The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…

困难
3609

到达目标点的最小移动次数

Find the minimum number of moves to reach a target point from a start point on a 2D grid with a math-driven solution.

困难
3614

用特殊操作处理字符串 II

Solve the problem of processing strings with special operations like '*' and '#' by simulating the rules left-to-right.

困难
3615

图中的最长回文路径

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

困难
3617

查找具有螺旋学习模式的学生

Solve Find Students with Study Spiral Pattern by validating each student's ordered subject cycle, consistency, and repea…

困难
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…

困难
3624

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

This problem challenges you to efficiently calculate the number of integers with popcount-depth equal to K using array a…

困难
3625

统计梯形的数目 II

Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…

困难
3630

划分数组得到最大异或运算和与运算之和

Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.

困难
3636

查询超过阈值频率最高元素

Find the majority element in subarrays that appear at least a threshold number of times, or -1 if none exists.

困难
3640

三段式数组 II

Trionic Array II is a challenging problem involving the sum of contiguous subarrays with special index constraints.

困难

该难度高频题型

route

Guided Practice Path

AI recommends problems by your level and tracks your progress.

Start Guided Patharrow_forward
LeetCode 困难难度题解