面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
盛最多水的容器
Find two vertical lines that can form a container with the most water in a given array of heights.
通配符匹配
Implement full wildcard pattern matching using '?' and '*' by applying state transition dynamic programming with careful…
跳跃游戏 II
Jump Game II requires finding the minimum jumps to reach the end of an array using dynamic programming and greedy techni…
跳跃游戏
Solve the Jump Game problem using state transition dynamic programming to determine if you can reach the last index of t…
买卖股票的最佳时机 II
Maximize stock profit by using a greedy approach to buy and sell multiple times, with state transition dynamic programmi…
加油站
The Gas Station problem requires finding the starting station index for a full circular trip with gas stations and costs…
分发糖果
The Candy problem is a greedy algorithm challenge where you need to minimize candy distribution while satisfying certain…
最大数
The problem asks to arrange integers to form the largest possible number, focusing on greedy algorithms and string handl…
去除重复字母
Remove duplicate letters from a string to produce the lexicographically smallest result using stack-based state manageme…
拼接最大数
Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.
摆动排序 II
Rearrange an array in a way that every odd-indexed element is greater than its adjacent even-indexed elements.
按要求补齐数组
Patching Array requires adding the minimum numbers to cover all sums from 1 to n using greedy choices and invariant chec…
递增的三元子序列
Identify if an array contains a strictly increasing triplet by maintaining a running minimal and middle value efficientl…
摆动序列
Find the longest wiggle subsequence in an integer array using state transition dynamic programming with greedy optimizat…
整数替换
Find the minimum number of operations to reduce a number to 1 by applying specific operations, using state transition dy…
移掉 K 位数字
Remove K Digits requires selecting which digits to drop using a monotonic stack for the smallest possible integer result…
最长回文串
Determine the length of the longest palindrome constructible from a given string using greedy counting and frequency tra…
分割数组的最大值
Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…
强密码检验器
The Strong Password Checker problem challenges you to optimize password strength while minimizing steps using greedy alg…
无重叠区间
Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…
用最少数量的箭引爆气球
Find the minimum number of arrows needed to burst all balloons by considering greedy choice and invariant validation.
分发饼干
Maximize content children by assigning at most one cookie per child using two-pointer scanning and greedy sorting techni…
IPO
Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…
超级洗衣机
Calculate the minimum moves to balance dresses across washing machines using a greedy strategy and invariant validation …
数组拆分
Maximize the sum of minimums of n pairs in a 2n integer array using a greedy pairing strategy efficiently.
最短无序连续子数组
Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.
种花问题
Determine if n new flowers can be planted in a flowerbed, ensuring no adjacent flowers using a greedy approach.
有效三角形的个数
Count all triplets in an integer array that satisfy the triangle inequality to form valid triangles efficiently using so…
任务调度器
Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…
数组列表中的最大距离
Maximum Distance in Arrays uses a greedy running minimum and maximum from previous arrays to validate cross array distan…
课程表 III
Solve the 'Course Schedule III' problem with a greedy approach involving course selection and validation of constraints.
最小区间
Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…
最长数对链
Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…
Dota2 参议院
The Dota2 Senate problem involves simulating voting rounds between Radiant and Dire senators until one party wins, using…
分割数组为连续子序列
Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.
最大交换
Given an integer, swap at most two digits once to produce the largest possible number using greedy digit selection.
有效的括号字符串
Solve the Valid Parenthesis String problem by leveraging state transition dynamic programming to handle parentheses and …
验证回文串 II
Check if a string can become a palindrome by deleting at most one character using two-pointer scanning and invariant tra…
买卖股票的最佳时机含手续费
Maximize stock trading profits accounting for per-transaction fees using state transition dynamic programming and greedy…
单调递增的数字
Determine the largest number less than or equal to n with digits in non-decreasing order using a greedy, invariant-drive…
设置交集大小至少为2
Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.
划分字母区间
Partition a string into maximal parts so that each letter appears in only one segment, using two-pointer scanning.
情侣牵手
This problem requires arranging couples sitting apart in a row with the minimum number of swaps using graph traversal an…
重构字符串
Reorganize a string so that no two adjacent characters are the same, if possible, using a greedy approach.
最多能完成排序的块 II
Determine the maximum number of chunks you can split an array into so that sorting each chunk results in a fully sorted …
最多能完成排序的块
The Max Chunks To Make Sorted problem requires you to split an array into the maximum number of chunks that can be sorte…
森林中的兔子
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
保持城市天际线
Maximize building heights in a city grid without changing the skyline, using greedy selection constrained by row and col…
安排工作以达到最大收益
Assign workers to jobs maximizing total profit using difficulty, profit, and worker arrays efficiently with binary searc…
一手顺子
Check if a hand of cards can be rearranged into groups of consecutive values.
雇佣 K 名工人的最低成本
Find the minimum cost to hire exactly k workers based on quality and wage expectations in this challenging greedy proble…
柠檬水找零
Determine if you can provide exact change to every customer at a lemonade stand using greedy bill management techniques.
翻转矩阵后的得分
Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.
优势洗牌
Maximize the advantage of nums1 over nums2 using a two-pointer greedy strategy, carefully tracking which elements beat o…
最低加油次数
Determine the minimum number of refueling stops needed to reach a target using dynamic programming and greedy strategies…
救生艇
Find the minimum number of boats required to save all people, using a two-pointer approach for efficient pairing.
最小差值 II
Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…
使括号有效的最少添加
Compute the minimum insertions needed to make a parentheses string valid using efficient stack-based state tracking tech…
戳印序列
Solve Stamping The Sequence with stack-based state management to convert string s to target using stamp efficiently.
增减字符串匹配
Reconstruct a permutation from a DI string using two-pointer scanning, carefully tracking the increasing and decreasing …
使数组唯一的最小增量
This problem challenges you to find the minimum moves to make all elements in an array unique by incrementing elements.
令牌放置
Maximize your score in the Bag of Tokens problem by strategically playing tokens with two-pointer scanning and greedy te…
二倍数对数组
Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.
删列造序 II
Solve the "Delete Columns to Make Sorted II" problem by applying greedy choices and invariant validation to string array…
煎饼排序
Sort an array using pancake flips, leveraging two-pointer scanning and invariant tracking to iteratively position the la…
三角形的最大周长
Given an integer array, find the largest perimeter of a triangle formed from three of these lengths.
不含 AAA 或 BBB 的字符串
Solve the problem of constructing a string without consecutive 'AAA' or 'BBB' by applying a greedy approach with invaria…
坏了的计算器
Compute the minimum operations to transform startValue into target using doubling and decrementing, leveraging a greedy …
K 次取反后最大化的数组和
Maximize the sum of an integer array after exactly k negations using a greedy approach and invariant tracking for optima…
行相等的最少多米诺旋转
Minimize domino rotations to make either row identical in the problem of Minimum Domino Rotations For Equal Row.
将数组分成和相等的三个部分
Determine if an array can be partitioned into three non-empty parts with equal sum using greedy choice and validation.
视频拼接
Solve the "Video Stitching" problem using state transition dynamic programming to cover a sporting event with minimum cl…
两地调度
Two City Scheduling requires selecting optimal city assignments for 2n people to minimize total travel costs efficiently…
交换一次的先前排列
Find the lexicographically largest permutation smaller than the given array using exactly one swap, leveraging a greedy …
距离相等的条形码
Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…
不同字符的最小子序列
The Smallest Subsequence of Distinct Characters problem asks you to find the lexicographically smallest subsequence of a…
受标签影响的最大值
Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.
叶值的最小代价生成树
Compute the minimum sum of non-leaf nodes in a binary tree formed from array leaves using dynamic programming efficientl…
递减元素使数组呈锯齿状
Transform any integer array into a zigzag pattern with minimal decrements using a targeted greedy approach and invariant…
段式回文
Solve the "Longest Chunked Palindrome Decomposition" problem by using dynamic programming and string manipulation techni…
玩筹码
Compute the minimum cost to move all chips to one position using parity-based greedy moves efficiently.
分割平衡字符串
Split a string into the maximum number of balanced substrings where each substring has an equal number of 'L' and 'R'.
交换字符使得字符串相同
This problem requires determining the minimum number of swaps to make two strings equal by swapping characters between t…
重构 2 行二进制矩阵
Reconstruct a 2-row binary matrix by distributing column sums while respecting upper and lower row limits using greedy p…
可被三整除的最大和
Find the maximum sum divisible by three from a given array using dynamic programming and state transition.
用户分组
Organize people into groups based on their specified group sizes using array scanning and hash table bucketing efficient…
划分数组为连续数字的集合
Determine if an integer array can be partitioned into sets of k consecutive numbers using array scanning and hash mappin…
6 和 9 组成的最大数字
Maximize a number by flipping at most one digit from 6 to 9 or vice versa.
灌溉花园的最少水龙头数目
Determine the minimum number of taps to water an entire garden using state transition dynamic programming and interval c…
破坏回文串
Given a palindrome, change exactly one character to make it non-palindromic and lexicographically smallest using a greed…
翻转子数组得到最大的数组值
Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.
数组大小减半
This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…
最多可以参加的会议数目
Maximize the number of events you can attend given their start and end days using a greedy strategy.
形成三的最大倍数
Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…
将二叉搜索树变平衡
This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.
最大的团队表现值
Maximize the performance of a team by selecting up to k engineers with the highest performance based on speed and effici…
安排电影院座位
Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…
3n 块披萨
Maximize your pizza slice sum from a 3n-sized circular array using state transition dynamic programming efficiently.
构造 K 个回文字符串
Determine if a string's characters can be rearranged to form exactly k non-empty palindrome strings using greedy validat…
做菜顺序
Maximize the sum of like-time coefficients by optimally choosing dishes to prepare in this dynamic programming problem.
非递增顺序的最小子序列
Find the minimum subsequence in non-increasing order such that its sum exceeds the sum of non-included elements.
最长快乐字符串
Solve the "Longest Happy String" problem using a greedy approach with validation of invariants for constructing the long…
和为 K 的最少斐波那契数字数目
Find the minimum number of Fibonacci numbers that sum up to a given integer k, using a greedy approach.
改变一个整数能得到的最大差值
Compute the maximum difference from changing digits in an integer using greedy choices and invariant checks efficiently.
检查一个字符串是否可以打破另一个字符串
This problem checks whether one string can break another using permutations and a greedy approach for comparison.
切割后面积最大的蛋糕
Maximize the area of a piece of cake after specified horizontal and vertical cuts using greedy algorithms and sorting.
不同整数的最少数目
Find the least number of unique integers after removing exactly k elements from an array using efficient frequency count…
避免洪水泛滥
This problem asks you to avoid flooding by deciding when to dry lakes between rain events.
最多 K 次交换相邻数位后得到的最小整数
Reorder digits using at most k adjacent swaps to produce the smallest possible integer, leveraging greedy selection effi…
三次操作后最大值与最小值的最小差
Find the minimum difference between the largest and smallest values in an array after performing at most three moves.
最多的不重叠子字符串
Find the maximum number of non-overlapping substrings in a given string, ensuring no two substrings intersect unless one…
形成目标数组的子数组最少增加次数
The problem asks for the minimum number of operations to transform an initial array of zeros into a target array using s…
最少的后缀翻转次数
Find the minimum number of operations to convert a binary string to a target string using bit flips.
排布二进制网格的最少交换次数
Compute the minimum number of adjacent row swaps to transform a binary grid so all upper-triangle cells are zero using a…
最大得分
Find the maximum possible score from two sorted arrays with a dynamic programming approach, leveraging partitioning and …
平衡括号字符串的最少插入次数
Compute the minimum insertions to transform a parentheses string into a balanced string using efficient stack tracking.
和为目标值且不重叠的非空子数组的最大数目
Find the maximum number of non-overlapping subarrays that sum to a given target using efficient scanning and hash lookup…
得到目标数组的最少函数调用次数
Calculate the minimum number of modify calls needed to convert an all-zero array into a given target array using greedy …
你可以获得的最大硬币数目
Solve the Maximum Number of Coins You Can Get using greedy pile selection and invariant validation to maximize your coin…
乘积为正数的最长子数组长度
Given an array, find the maximum length of a subarray with a positive product using dynamic programming.
使绳子变成彩色的最短时间
Minimize the time Bob needs to remove balloons to make a rope colorful using dynamic programming with state transitions.
检查字符串是否可以通过排序子字符串得到另一个字符串
This problem requires checking if string 's' can be transformed into string 't' using substring sort operations.
所有排列中的最大和
Maximize the total sum of requests on nums by greedily assigning larger numbers to most frequently requested indices.
给定行和列的和求可行矩阵
Given row and column sums, find any valid matrix of non-negative integers that satisfies them.
找到处理最多请求的服务器
Given k servers and a series of requests, find the busiest server(s) using greedy strategies and efficient server tracki…
可以到达的最远建筑
Furthest Building You Can Reach explores a greedy approach with heap-based optimization to find the maximum reachable bu…
字符频次唯一的最小删除次数
Determine the minimum deletions needed to ensure all character frequencies in a string are unique using a greedy approac…
销售价值减少的颜色球
Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.
具有给定数值的最小字符串
Find the lexicographically smallest string of length n with a given numeric value k using a greedy approach.
完成所有任务的最少初始能量
Determine the minimum initial energy needed to finish all tasks using a greedy ordering based on required versus actual …
得到山形数组的最少删除次数
Solve the problem of finding the minimum number of removals to make a given array a mountain array using dynamic program…
找出最具竞争力的子序列
Identify the lexicographically smallest subsequence of size k using stack-based greedy selection in array traversal.
数组的最小偏移量
Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…
石子游戏 VI
Determine the winner in Stone Game VI using a greedy strategy that accounts for each stone's dual value impact on Alice …
十-二进制数的最少数目
This problem asks to find the minimum number of deci-binary numbers needed to sum to a given number represented as a str…
修改后的最大二进制字符串
The problem asks to maximize a binary string using specific operations to get the highest possible value.
得到连续 K 个 1 的最少相邻交换次数
Find the minimum number of adjacent swaps to gather k consecutive ones in a binary array using sliding window logic.
吃苹果的最大数目
Maximize apples eaten by choosing the best apples first, considering their rot days and available days to eat them.
卡车上的最大单元数
Maximize total units loaded on a truck by choosing boxes greedily based on highest units per box within truck capacity l…
得到子序列的最少操作次数
Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…
删除子字符串的最大得分
Compute the highest score by greedily removing specific substrings using a stack to track state transitions efficiently.
重新排列后的最大子矩阵
Rearrange columns of a binary matrix to find the largest submatrix of 1s.
需要教语言的最少人数
Minimize the number of users to teach a language that ensures all friends can communicate in a social network.
替换隐藏数字得到的最晚时间
Determine the latest valid time by replacing hidden digits using a greedy choice and invariant validation strategy effic…
放置盒子
Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.
移除石子的最大得分
Maximize the score in a solitaire game by optimally removing stones from three piles with a greedy approach.
构造字典序最大的合并字符串
Construct the lexicographically largest merge from two strings using a two-pointer greedy scanning approach efficiently.
通过连接另一个数组的子数组得到一个数组
Determine if you can sequentially select disjoint subarrays from nums matching each group in order using two-pointer sca…
通过最少操作次数使数组的和相等
Solve the problem of balancing the sums of two integer arrays with minimal operations, using array scanning and hash loo…
构成特定和需要添加的最少元素
Compute the gap between current sum and goal, then greedily cover it with limit-sized additions to get the minimum count…
最大平均通过率
Maximize the average pass ratio by assigning extra guaranteed-passing students using a greedy heap strategy for optimal …
你能构造出连续值的最大数目
Find the maximum number of consecutive integer values starting from zero that can be formed using your coins array.
有界数组中指定下标处的最大值
Maximize the value at a given index of an array with constraints using binary search over the valid answer space.
最少侧跳次数
Solve the Minimum Sideway Jumps problem using state transition dynamic programming to minimize side jumps while navigati…
最少操作使数组递增
Calculate the minimum number of increments required to transform a given integer array into a strictly increasing sequen…
雪糕的最大数量
Maximize the number of ice cream bars a boy can buy by applying a greedy choice strategy based on cost sorting.
最高频元素的频数
Maximize the frequency of an element in an array by incrementing at most `k` elements. Use binary search and greedy tech…
减小和重新排列数组后的最大元素
Determine the maximum value in an array after decreasing elements and rearranging using a greedy invariant approach.
邻位交换的最小次数
Find the minimum number of adjacent swaps to reach the kth smallest wonderful integer from a given number string.
构成交替字符串需要的最小交换次数
This problem requires finding the minimum number of swaps to make a binary string alternating or determine if it's impos…
数组中最大数对和的最小值
Minimize the maximum pair sum in an array by optimally pairing its elements.
插入后的最大值
Solve Maximum Value after Insertion by greedily placing x at the first digit that makes the resulting signed number larg…
合并若干三元组以形成目标三元组
Determine if target triplet can be formed by merging given triplets using greedy selection and invariant checks.
字符串中的最大奇数
Find the largest odd number in a string using a greedy approach with careful digit inspection and invariant checks.
消灭怪物的最大数量
Eliminate monsters by strategically using a weapon in a video game to stop them before they reach your city.
求和游戏
Determine if Alice can force a win in the Sum Game by strategically replacing '?' using a greedy and invariant approach.
新增的最少台阶数
Determine the fewest rungs to add to climb a strictly increasing ladder using a greedy step-by-step approach.
子字符串突变后可能得到的最大整数
Find the largest integer by mutating a substring of a number using a mapping array for each digit.
你可以工作的最大周数
Maximize the number of weeks you can work on projects with milestone constraints using a greedy approach and invariant v…
移除石子使总数最小
Minimize the total stones by repeatedly removing half from the largest pile using a greedy heap strategy.
使字符串平衡的最小交换次数
Determine the minimum swaps to balance a bracket string using two-pointer scanning with invariant tracking efficiently.
构造元素不等于两相邻元素平均值的数组
Rearrange an array such that no element equals the average of its neighbors using a greedy approach.
数组元素的最小非零乘积
The problem asks to minimize the product of an array after performing bit-swapping operations on its binary representati…
使用特殊打字机键入单词的最少时间
Compute the minimum typing time by greedily taking the shorter circular move between consecutive letters, then adding on…
最大方阵和
Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.
游戏中弱角色的数量
Identify all weak characters in a game by analyzing attack and defense values using a stack-based greedy sorting approac…
从双倍数组中还原原数组
Given a shuffled array, determine if it is a doubled array and find the original array.
重复 K 次的最长子序列
Find the longest subsequence repeated k times in a string using backtracking search with pruning.
转换字符串的最少操作次数
Minimize moves to convert a string of 'X' and 'O' to all 'O' by converting three consecutive characters to 'O'.
石子游戏 IX
In the Stone Game IX problem, Alice and Bob take turns removing stones, and Alice wins if the sum of removed stones is d…
含特定字母的最小子序列
Find the lexicographically smallest subsequence of length k with at least repetition occurrences of a given letter using…
使每位学生都有座位的最少移动次数
Calculate the minimum total moves to seat each student using greedy assignment and invariant validation efficiently.
如果相邻两个颜色均相同则删除当前颜色
Alice and Bob play a game removing colored pieces; Alice wins if she makes the last valid move.
分配给商店的最多商品的最小值
Distribute products to stores so the largest store allocation is minimized using binary search over possible maximums.
你可以安排的最多任务数目
Maximize the number of tasks that can be completed by efficiently using workers and magical pills.
两栋颜色不同且距离最远的房子
Maximize the distance between two houses with different colors by using a greedy approach and validating the choice.
喂食仓鼠的最小食物桶数
Find the minimum number of food buckets required to feed all hamsters, using dynamic programming and greedy techniques.
网格图中机器人回家的最小代价
Find the minimum cost for a robot to return home in a grid with row and column movement costs.
从数组中移除最大值和最小值
The problem asks to remove the minimum and maximum elements from an array with the fewest deletions.
判断一个括号字符串是否有效
Determine if a parentheses string can be transformed into a valid sequence considering locked positions using stack logi…
摧毁小行星
This problem requires destroying asteroids by choosing the right order of collisions based on mass, using a greedy appro…
连接两字母单词得到的最长回文串
Find the maximum-length palindrome by combining two-letter words using array scanning and hash table lookups efficiently…
用邮票贴满网格图
Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…
全部开花的最早一天
Find the earliest day where all flower seeds are blooming based on their planting and growth times, using a greedy strat…
得到目标值的最少行动次数
Calculate the fewest steps to reach a target integer using increments and limited doubles with a greedy strategy.
同时运行 N 台电脑的最长时间
Solve the problem of determining the maximum running time of n computers using a set of batteries.
打折购买糖果的最小开销
Minimize the total cost of buying candies using a greedy approach with a discount system based on candy prices.
拆分数位后四位数字的最小和
Find the minimum sum of two 2-digit numbers by splitting a four-digit number into two integers.
使数组变成交替数组的最少操作数
Given an array, calculate the minimum number of operations needed to make it alternating.
拿出最少数目的魔法豆
Determine the minimum beans to remove so all remaining non-empty bags have equal beans using a greedy approach.
拆分成最多数目的正偶数之和
Determine the largest set of unique positive even integers that sum to a given finalSum using backtracking and greedy se…
构造限制重复的字符串
Construct a lexicographically largest string from a given string with no letter appearing more than a repeatLimit times …
得到回文串的最少操作次数
The problem challenges you to find the minimum number of adjacent swaps to make a string a palindrome.
向数组中追加 K 个整数
In this problem, you need to append k unique positive integers to a given array nums such that the sum is minimized.
K 次操作后最大化顶端元素
Maximize the topmost element in a pile after making exactly k moves using a greedy strategy and invariant checks.
字符串中最多数目的子序列
Maximize the number of subsequences by optimally adding a character to a given string to match a specified pattern.
将数组和减半的最少操作次数
Minimize operations to halve an array's sum using greedy choices and heap data structures.
美化数组的最少删除数
Determine the minimum deletions required to transform an array into a beautiful sequence using stack-based state managem…
转化时间需要的最少操作数
The problem asks to find the minimum number of operations to convert one time string to another using specific time incr…
K 次增加后的最大乘积
Maximize the product of an array after performing up to k increments using a greedy approach with heap optimization.
花园的最大总美丽值
Determine the maximum total beauty of gardens by strategically planting flowers using binary search over achievable flow…
设计一个 ATM 机器
Design an ATM machine that stores and withdraws money with given denominations and prioritizes larger values during with…
完成所有任务需要的最少轮数
The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.
移除指定数字得到的最大结果
Determine the largest possible number by removing one specific digit using a greedy approach and string iteration.
毯子覆盖的最多白色砖块数
Solve Maximum White Tiles Covered by a Carpet by sorting intervals, checking optimal carpet starts, and counting full pl…
装满石头的背包的最大数量
Maximize the number of bags filled to capacity by distributing additional rocks using a greedy approach.
道路的最大总重要性
Assign unique values to cities to maximize the total importance of all roads using greedy selection based on city connec…
划分数组使最大差为 K
Find the minimum number of subsequences required such that the difference between the maximum and minimum value in each …
个位数字为 K 的整数之和
Determine the minimum set of positive integers whose units digits match k and sum exactly to num using DP patterns.
小于等于 K 的最长二进制子序列
Find the longest subsequence in a binary string that forms a number less than or equal to a given integer k.
最小差值平方和
Calculate the minimum sum of squared differences between two arrays using limited modifications and binary search techni…
装满杯子需要的最短总时长
Determine the minimum seconds to fill cups of cold, warm, and hot water using a greedy selection strategy and invariant …
不可能得到的最短骰子序列
Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…
使数组中所有元素都等于零
Minimize operations to make all array elements zero by subtracting equal amounts in each operation.
分组的最大数量
Determine the maximum number of ordered non-empty student groups for a competition using grades array analysis and binar…
将数组排序的最少替换次数
Minimize the number of operations to make the array sorted in non-decreasing order by replacing elements with sums of tw…
根据模式串构造最小数字
Construct the lexicographically smallest string that fits the increasing and decreasing conditions of a given pattern.
赢得比赛需要的最少训练时长
Find the minimum hours of training needed to beat all opponents in a competition based on energy and experience.
最大回文数字
Form the largest palindromic number from a string of digits while maintaining a valid palindrome structure.
和有限的最长子序列
Find the maximum size of a subsequence from nums with a sum less than or equal to each query value.
子字符串的最优划分
Given a string s, partition it into substrings with unique characters and return the minimum number of substrings.
将区间分为最少组数
Determine the minimum number of non-overlapping groups for a set of intervals using precise two-pointer scanning logic.
运动员和训练师的最大匹配数
Maximize the number of valid player-trainer matchings using two-pointer scanning and careful sorting strategy.
完成所有交易的初始最少钱数
Find the minimum money required to complete all transactions in any order while considering cost and cashback.
最小异或
Minimize XOR problem asks for an integer that minimizes XOR with another, applying greedy choices for bit manipulation.
使用机器人打印字典序最小的字符串
Solve the problem of using a robot to print the lexicographically smallest string with stack-based state management.
最小化数组中的最大值
Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …
使数组相等的最小开销
Find the minimum cost to make all elements of an array equal by using binary search over valid answers.
使数组相似的最少操作次数
Determine the minimum operations to make two arrays similar by adjusting pairs while respecting element frequencies and …
美丽整数的最小增量
Find the minimum addition to a number such that its digits sum to a value less than or equal to a given target.
不重叠回文子字符串的最大数目
Find the maximum number of non-overlapping palindromic substrings of at least length k in a string using dynamic program…
追加字符以获得子序列
Determine the minimum characters to append to s so t becomes a subsequence using efficient two-pointer scanning techniqu…
图中最大星和
Find the maximum star sum in a graph with specific node values and edges, using greedy algorithms to select the optimal …
青蛙过河 II
Frog Jump II requires finding the minimal maximum jump length for a frog to traverse stones forward and backward efficie…
让数组不相等的最小总代价
Calculate the minimum cost to rearrange nums1 so that no element matches nums2 using optimal swaps and hash counting.
礼盒的最大甜蜜度
Maximize the tastiness of a candy basket by choosing k candies from a list of candy prices.
将字符串分割成值不超过 K 的子字符串
Determine the minimum number of substrings from a numeric string such that each substring value does not exceed k using …
最大化城市的最小电量
Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…
执行 K 次操作后的最大分数
Maximize your score by applying exactly k operations on an array using greedy selection and heap optimization techniques…
使数组中所有元素相等的最小操作数 II
Calculate the minimum operations to make two integer arrays equal using greedy adjustments with modular checks efficient…
最大子序列的分数
Maximize the score of a subsequence by selecting indices based on nums1 and nums2, using a greedy approach and sorting.
将珠子放入背包中
The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…
从一个范围内选择最多整数 I
Determine the maximum count of integers from 1 to n avoiding banned numbers while keeping the sum under maxSum.
打家劫舍 IV
House Robber IV requires calculating minimum maximum money the robber can take using state transition dynamic programmin…
重排水果
Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…
替换一个数字后的最大差值
Find the largest difference by remapping a single digit in a number using a greedy approach to maximize and minimize out…
修改两个元素的最小分数
The problem asks for the minimum score after changing two elements of an array using a greedy approach.
将整数减少到零需要的最少操作数
Compute the minimum number of operations to reduce a positive integer to zero using additions or subtractions of powers …
找出对应 LCP 矩阵的字符串
Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.
求出最多标记下标
Maximize marked indices in an array by performing allowed operations, applying binary search to find the optimal count e…
最小和分割
Split a positive integer into two parts to minimize their sum using a greedy approach and sorting.
重排数组以得到最大前缀分数
Maximize the number of positive prefix sums by rearranging an integer array using a greedy, order-focused strategy.
完成所有任务的最少时间
Determine the minimum active time for a computer to complete all scheduled tasks within their specific time windows effi…
将钱分给最多的儿童
Determine the maximum number of children who can each receive exactly 8 dollars using a greedy approach with validation …
最大化数组的伟大值
Maximize Greatness of an Array requires permuting numbers to exceed original values at most indices efficiently.
执行操作后的最大 MEX
Find the smallest missing non-negative integer after repeated additions or subtractions of a given value in nums array e…
K 件物品的最大和
Select k items from a bag containing 1, 0, and -1 to maximize sum using greedy choice and invariant validation strategie…
质数减法运算
Determine if it's possible to make the array strictly increasing using prime subtractions.
使子数组元素和相等
Solve Make K-Subarray Sums Equal by grouping circular indices with gcd cycles and minimizing each group to its median.
老鼠和奶酪
In 'Mice and Cheese', you must maximize the total reward of two mice eating cheese while respecting their preferences an…
最小化数对的最大差值
Minimize the Maximum Difference of Pairs seeks to optimize the maximum pairwise difference in a set of index pairs from …
构造有效字符串的最少插入数
Determine the minimum insertions required to transform a given string into repeated concatenations of 'abc' using dynami…
K 个元素的最大和
Maximize your score by performing exactly k operations on an array using a greedy approach to select the highest values.
将数组清空
Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.
字典序最小的美丽字符串
Find the lexicographically smallest beautiful string larger than the given string using greedy choice and invariant vali…
使二叉树所有路径值相等的最小代价
Minimize the cost increments required to equalize path costs in a binary tree from root to leaves.
最大或值
Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.
字典序最小回文串
Given a string, make it a palindrome with the fewest operations, prioritizing lexicographically smallest result.
购买两块巧克力
Determine the leftover money after buying exactly two chocolates using a greedy selection and sum validation approach.
一个小组的最大实力值
Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…
使所有字符相等的最小成本
Find the minimum cost to make all characters of a binary string equal by performing two types of operations.
执行子串操作后的字典序最小字符串
Given a string, perform operations to make it lexicographically smaller using a greedy approach with substring modificat…
构造最长的新字符串
Maximize the length of a string built from AA, BB, and AB without creating triple repeats using DP and greedy logic.
合并后数组中的最大元素
This problem focuses on applying greedy choices and merging elements to find the largest element in an array.
长度递增组的最大数目
Maximize the number of groups that can be formed with given usage limits, leveraging binary search for optimal solutions…
包含三个字符串的最短字符串
Find the shortest string containing three given strings using a greedy approach while ensuring it is lexicographically s…
判断是否能拆分数组
Determine whether an array can be fully split into single-element subarrays using a state transition dynamic programming…
子序列最大优雅度
Maximize elegance of a k-length subsequence from a list of items with profits and categories.
操作使得分最大
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
k-avoiding 数组的最小总和
Determine the minimum sum of a k-avoiding array by choosing distinct integers such that no pair sums to a given k.
找出美丽数组的最小和
Find the minimum possible sum of a beautiful array that satisfies the given conditions with the greedy approach.
使子序列的和等于目标的最少操作次数
The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …
统计一个字符串的 k 子序列美丽值最大的数目
Determine the number of k-length unique subsequences in a string that maximize the sum of character frequencies efficien…
生成特殊数字的最少操作
Minimize operations to make a number divisible by 25 by deleting digits. Use greedy choice and invariant validation.
删除数对后的最小数组长度
This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.
最大二进制奇数
Rearrange a binary string to form the largest odd binary number using a greedy approach and least significant bit valida…
使数组为空的最少操作次数
Minimize the number of operations to make an array empty by leveraging array scanning and hash lookup.
将数组分割成最多数目的子数组
Maximize the number of subarrays in an array while ensuring each subarray's bitwise AND meets the minimum score requirem…
最小处理时间
Determine the minimum total processing time by optimally assigning tasks to multiple processors using a greedy approach.
对数组执行操作使平方和最大
Maximizing the sum of squares in an array through bitwise operations on selected elements.
最长相邻不相等子序列 I
Find the longest alternating subsequence in a string array based on a binary group array.
合法分组的最少组数
The problem involves sorting balls into boxes while minimizing the number of boxes, adhering to size constraints.
数组的最小相等和
Find the minimum sum where two arrays become equal after replacing all zeros with positive integers using a greedy strat…
购买物品的最大开销
Maximize spending by carefully choosing the right items across multiple shops over m * n days.
区分黑球与白球
Solve the "Separate Black and White Balls" problem by swapping adjacent balls to group all black balls to the right with…
最大异或乘积
Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.
需要添加的硬币的最小数量
Determine the minimum number of coins to add so all values up to target are obtainable using a greedy sum approach.
消除相邻近似相等字符
Minimize operations to remove adjacent almost-equal characters using dynamic programming and greedy methods.
划分数组并满足最大差限制
Divide an array into subarrays with a maximum element difference under a given threshold using a greedy approach.
使数组成为等数数组的最小代价
Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…
找到最大周长的多边形
Determine the largest perimeter polygon from a set of side lengths using a greedy approach with invariant validation che…
移除后集合的最多元素数
Maximize a set size by strategically removing half of elements from two arrays using hash lookups and array scanning.
通过操作使数组长度最小
Minimize the length of an integer array through a series of operations, using a greedy approach with modular arithmetic.
输入单词需要的最少按键次数 I
Calculate the minimum pushes to type a word using a remapped telephone keypad with greedy allocation of letters.
输入单词需要的最少按键次数 II
Given a word, find the minimum number of pushes to type it on a remapped keypad using a greedy approach.
给定操作次数内使剩余元素的或值最小
Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.
回文字符串的最大数量
The problem focuses on maximizing the number of palindromes that can be formed from a given list of words through specif…
标记所有下标的最早秒数 II
This problem asks to determine the earliest second at which all indices in an array can be marked using a sequence of op…
最大节点价值之和
Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…
重新分装苹果
Distribute packs of apples into boxes using a greedy strategy, minimizing the number of boxes selected efficiently and c…
幸福值最大化的选择方案
Maximize the happiness of selected children by choosing the k happiest ones and applying greedy strategies to minimize l…
替换字符串中的问号使分数最小
Minimize the cost of a string with '?' characters by replacing them with letters in lexicographical order while minimizi…
成为 K 特殊字符串需要删除的最少字符数
Minimize deletions to make a string k-special by adjusting character frequencies.
拾起 K 个 1 需要的最少行动次数
Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.
执行操作使数据元素之和大于等于 K
Given an array nums, find the minimum number of operations to make the sum of elements greater than or equal to k.
满足距离约束且字典序最小的字符串
Minimize a string lexicographically using a series of operations constrained by a given integer k.
使数组中位数等于 K 的最少操作数
The problem involves minimizing operations to make the median of an array equal to a given value k using a greedy approa…
覆盖所有点的最少矩形数目
Find the minimum number of rectangles needed to cover all points, given constraints on width and position.
使数组中所有元素相等的最小开销
Compute the minimum cost to make all elements equal using selective operations guided by greedy choices and invariant ch…
删除星号以后字典序最小的字符串
Find the lexicographically smallest string by removing stars using stack-based state management and careful character se…
使二进制数组全部等于 1 的最少操作次数 II
Solve the Minimum Operations to Make Binary Array Elements Equal to One II using state transition dynamic programming ef…
与敌人战斗后的最大分数
Solve the "Maximum Points After Enemy Battles" problem by maximizing points through greedy choices with energy validatio…
交换后字典序最小的字符串
Lexicographically Smallest String After a Swap involves finding the smallest string after swapping adjacent digits with …
切蛋糕的最小总开销 I
In this problem, you need to minimize the cost of cutting a cake into 1x1 pieces using vertical and horizontal cuts.
切蛋糕的最小总开销 II
Solve Minimum Cost for Cutting Cake II by choosing optimal cuts using a greedy strategy while tracking cost increments p…
将 1 移动到末尾的最大操作次数
This problem requires finding the maximum number of operations to move ones to the end of a binary string.
使数组等于目标数组所需的最少操作次数
This problem requires calculating the minimum number of operations to transform one array into another using state trans…
新增道路查询后的最短距离 II
The problem involves calculating the shortest path from city 0 to city n-1 after each road addition, leveraging greedy c…
找出最大的 N 位 K 回文数
Compute the largest n-digit integer divisible by k that forms a palindrome using state transition dynamic programming te…
对 Bob 造成的最少伤害
Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.
范围内整数的最大得分
Maximize Score of Numbers in Ranges asks to find the maximum score by selecting integers within given intervals with a f…
到达数组末尾的最大得分
Calculate the maximum score to reach the end of an array using greedy jumps based on array values and distances.
移山所需的最少秒数
Determine the minimum seconds required to reduce a mountain to zero height using simultaneous workers efficiently.
高度互不相同的最大塔高和
Assign heights to towers ensuring each height is unique and the total sum is maximized using greedy sorting techniques.
字典序最小的合法序列
Determine the lexicographically smallest valid index sequence by using state transition dynamic programming over word1 a…
使数组非递减的最少除法操作次数
Determine the minimum number of division operations to make an array non-decreasing using a greedy and invariant-based s…
最小可整除数位乘积 II
Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…
最小化相邻元素的最大差值
Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.
零数组变换 III
Zero Array Transformation III requires removing the minimum number of queries to make all elements zero using greedy val…
执行操作后不同元素的最大数量
Maximize distinct elements in an array by performing at most one operation on each element.
使每一列严格递增的最少操作次数
Calculate the minimum increments to make each column of a matrix strictly increasing using a greedy invariant approach.
收集连续 K 个袋子可以获得的最多硬币数量
Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…
将数组变相同的最小代价
Minimize cost to make arrays identical by performing operations with given constraints and a greedy strategy.
子数组操作后的最大频率
Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…
重新安排会议得到最多空余时间 I
Maximize free time by rescheduling up to k non-overlapping meetings within a fixed event using sliding window updates.
重新安排会议得到最多空余时间 II
Maximize free time by rescheduling at most one meeting using a greedy choice with invariant validation approach for arra…
最大化游戏分数的最小值
Maximizing the minimum score after at most m moves, leveraging binary search and greedy strategies over an array of scor…
吃披萨
Maximize the total weight gained by optimally eating pizzas in groups of four using greedy selection and invariant valid…
选择 K 个互不重叠的特殊子字符串
Determine if k non-overlapping special substrings exist in a string using dynamic programming and careful substring trac…
提取至多 K 个元素的最大总和
Find the maximum sum by selecting at most k elements from a 2D matrix respecting per-row limits using a greedy strategy.
正方形上的点之间的最大距离
Select k points on a square boundary to maximize minimum Manhattan distance using binary search and greedy placement str…
字典序最小的生成字符串
Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.
删除后的最大子数组元素和
Maximize the sum of a subarray after performing deletions, ensuring elements remain unique.
非递减数组的最大长度
Determine the maximum size of a non-decreasing array by replacing subarrays with their maximum values efficiently.
针对图的路径存在性查询 II
Solve path existence queries in a graph using binary search on the answer space, focusing on sorted nodes and maximum di…
将所有元素变为 0 的最少操作次数
Calculate the fewest operations to turn all numbers in an array to zero using subarray minimum elimination strategy.
不同字符数量最多为 K 时的最少删除数
You need to delete characters in a string to reduce its distinct characters to at most k.
图中边值的最大和
Maximize the sum of edge values in a connected graph by assigning unique node values and optimizing edge products.
不相交子字符串的最大数量
Determine the maximum number of non-overlapping substrings in a word, each at least four characters and matching start-e…
选择不同 X 值三元组使 Y 值之和最大
Select three distinct x-values from arrays to maximize the sum of their corresponding y-values efficiently using hashing…
数组元素相等转换
Transform Array to All Equal Elements requires careful greedy choices and validating invariants to achieve uniformity ef…
字符串转换需要的最小操作数
Transform word1 into word2 using minimal operations on substrings with a dynamic programming state transition approach.
最小相邻交换至奇偶交替
Compute the minimum adjacent swaps to make array elements alternate between even and odd using greedy and invariant chec…
找到最大三角形面积
Find the maximum area of a triangle from 2D coordinates with at least one side parallel to the x-axis or y-axis.
升级后最大生成树稳定性
Maximizing the stability of a spanning tree with upgrades requires careful optimization of edge strengths using binary s…
数组的最小稳定性因子
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
划分数组得到最大异或运算和与运算之和
Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.