面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
两数之和
Two Sum is solved fastest by storing seen values in a hash map and checking each number's needed complement once.
寻找两个正序数组的中位数
Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.
盛最多水的容器
Find two vertical lines that can form a container with the most water in a given array of heights.
最长公共前缀
Find the longest common prefix in an array of strings, returning an empty string if none exists.
三数之和
Given an integer array, return all unique triplets where the sum is zero using two-pointer scanning with careful duplica…
最接近的三数之和
Find the sum of three integers in an array that is closest to a given target using two-pointer scanning.
四数之和
The 4Sum problem requires finding all unique quadruplets in an array that sum to a specific target value.
删除有序数组中的重复项
Learn how to remove duplicates from a sorted array in-place using two-pointer scanning while preserving element order.
移除元素
Remove Element challenges you to remove a value from an array in-place using efficient two-pointer scanning and tracking…
下一个排列
Next Permutation is a medium-difficulty problem focusing on generating the next lexicographically greater permutation of…
搜索旋转排序数组
Find the index of a target in a rotated sorted array using a careful binary search that handles pivot shifts.
在排序数组中查找元素的第一个和最后一个位置
Locate the first and last index of a target in a sorted array using binary search for precise O(log n) performance.
搜索插入位置
Find the correct index for a target value in a sorted array using binary search, or return the position where it should …
有效的数独
Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …
解数独
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
组合总和
Find all unique combinations of numbers from a distinct array that sum to a target using controlled backtracking search.
组合总和 II
Find all unique combinations of numbers that sum to a target using backtracking with careful pruning to avoid duplicates…
缺失的第一个正数
Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…
接雨水
Calculate the total trapped rain water using the elevation map array, leveraging dynamic programming and two-pointer pat…
跳跃游戏 II
Jump Game II requires finding the minimum jumps to reach the end of an array using dynamic programming and greedy techni…
全排列
Generate all possible orderings of a distinct integer array using backtracking search with careful pruning to avoid dupl…
全排列 II
Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…
旋转图像
Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…
字母异位词分组
Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.
N 皇后
Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…
最大子数组和
Maximum Subarray is a classic state transition dynamic programming problem about deciding whether to extend or restart a…
螺旋矩阵
Given an m x n matrix, return all elements in spiral order starting from the top-left corner.
跳跃游戏
Solve the Jump Game problem using state transition dynamic programming to determine if you can reach the last index of t…
合并区间
Merge Intervals requires sorting an array of interval pairs and combining overlaps efficiently using sequential comparis…
插入区间
Given a sorted array of non-overlapping intervals, insert a new interval and merge any overlapping intervals.
螺旋矩阵 II
Generate a spiral matrix of size n x n, filled with elements from 1 to n² in spiral order, for interview-focused solving…
不同路径 II
Calculate the number of unique paths from top-left to bottom-right in a grid with obstacles using dynamic programming st…
最小路径和
Compute the minimum sum from top-left to bottom-right in a grid using state transition dynamic programming efficiently.
加一
Given a number as an array of digits, increment it by one and return the updated array of digits.
文本左右对齐
Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.
矩阵置零
Modify the matrix in place by setting rows and columns to zero when an element is zero.
搜索二维矩阵
Search a 2D matrix efficiently using binary search over its linearized index, ensuring correctness in row-major sorted a…
颜色分类
Sort Colors requires in-place reordering of an array using a two-pointer scanning strategy to group 0s, 1s, and 2s effic…
子集
Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.
单词搜索
Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.
删除有序数组中的重复项 II
Solve the problem of removing duplicates from a sorted array in-place, ensuring each element appears at most twice, usin…
搜索旋转排序数组 II
Determine if a target exists in a rotated sorted array that may contain duplicates using a binary search variation effic…
柱状图中最大的矩形
Find the maximal rectangular area in a histogram using stack-based state management for precise bar tracking and width c…
最大矩形
Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…
合并两个有序数组
Merge two sorted arrays into the first array in non-decreasing order, using a two-pointer approach.
子集 II
Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…
从前序与中序遍历序列构造二叉树
Construct a binary tree using preorder and inorder traversal arrays, leveraging array scanning and hash table lookups.
从中序与后序遍历序列构造二叉树
Reconstruct a binary tree from given inorder and postorder arrays using array scanning and hash lookup to optimize recur…
将有序数组转换为二叉搜索树
Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.
杨辉三角
Generate the first numRows of Pascal's Triangle using dynamic programming with clear state transitions and array manipul…
杨辉三角 II
Compute the specific row of Pascal's Triangle using efficient state transition dynamic programming with array-based upda…
三角形最小路径和
Given a triangle, return the minimum path sum from top to bottom, moving to adjacent numbers in the row below.
买卖股票的最佳时机
Maximize stock profit by identifying the optimal buy and sell days using dynamic programming.
买卖股票的最佳时机 II
Maximize stock profit by using a greedy approach to buy and sell multiple times, with state transition dynamic programmi…
买卖股票的最佳时机 III
Determine the maximum profit from at most two stock transactions using state transition dynamic programming on price arr…
最长连续序列
Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.
被围绕的区域
Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.
加油站
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…
只出现一次的数字
Solve the Single Number problem using an efficient approach with constant space and linear time complexity.
只出现一次的数字 II
Find the single element in an array where every other element appears three times, using bit manipulation and constant s…
单词拆分
Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…
单词拆分 II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
直线上最多的点数
Find the maximum number of points on a straight line in a 2D plane using array scanning and hash lookup.
逆波兰表达式求值
Compute the result of an arithmetic expression in Reverse Polish Notation using a stack to manage operands efficiently.
乘积最大子数组
Find the subarray with the largest product in an integer array using dynamic programming techniques.
寻找旋转排序数组中的最小值
Find the minimum element in a rotated sorted array using binary search to efficiently identify the point of rotation.
寻找旋转排序数组中的最小值 II
Find the minimum in a rotated sorted array with possible duplicates using binary search.
寻找峰值
Find Peak Element leverages binary search for efficiently locating a peak in an array, a problem commonly asked in techn…
最大间距
Find the largest difference between successive elements in a sorted array efficiently using linear time techniques and b…
两数之和 II - 输入有序数组
Solve the Two Sum II problem efficiently using binary search over a valid answer space in a sorted array.
多数元素
Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.
地下城游戏
Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …
最大数
The problem asks to arrange integers to form the largest possible number, focusing on greedy algorithms and string handl…
买卖股票的最佳时机 IV
Determine the maximum profit from at most k stock transactions using state transition dynamic programming on an array of…
轮转数组
Rotate Array challenges you to shift elements right by k steps using precise two-pointer scanning and invariant tracking…
打家劫舍
Maximize the amount of money you can rob tonight without alerting the police by applying dynamic programming with state …
岛屿数量
Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…
计数质数
Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.
长度最小的子数组
Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.
单词搜索 II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
打家劫舍 II
Maximize your loot by robbing houses arranged in a circle without alerting the police using dynamic programming.
数组中的第K个最大元素
Find the kth largest element in an unsorted array using optimal approaches like Quickselect or heaps.
组合总和 III
Find all unique combinations of k numbers adding to n using efficient backtracking with pruning in arrays.
存在重复元素
Determine if an integer array contains any duplicate values by efficiently scanning with a hash lookup to ensure fast de…
天际线问题
The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …
存在重复元素 II
Check if any two equal numbers exist within k indices using array scanning and hash table lookup efficiently.
存在重复元素 III
The problem involves finding a pair of indices in an array where the index and value differences are within given limits…
最大正方形
Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.
汇总区间
Summary Ranges involves converting a sorted array of unique integers into a minimal list of range strings.
多数元素 II
Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…
除了自身以外数组的乘积
Solve the 'Product of Array Except Self' problem by calculating the product of all elements except self for each index e…
滑动窗口最大值
Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…
搜索二维矩阵 II
Efficiently search for a target in a 2D matrix using binary search and matrix properties.
只出现一次的数字 III
Find the two unique numbers in an array where all other numbers appear exactly twice using bit manipulation efficiently.
丢失的数字
Find the missing number in an array containing distinct numbers in the range [0, n].
H 指数
Determine a researcher's h-index by analyzing citations using array sorting and counting techniques efficiently and accu…
H 指数 II
Compute a researcher's H-Index from a sorted citation array using binary search over the valid answer space efficiently.
移动零
Move all zeros in an array to the end while preserving the order of non-zero elements using efficient in-place operation…
窥视迭代器
Design an iterator with peek functionality, adding to the standard next and hasNext operations for efficient element acc…
寻找重复数
The problem involves finding the duplicate number in an array of integers, using a binary search approach over the valid…
生命游戏
Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…
最长递增子序列
Solve the Longest Increasing Subsequence problem using dynamic programming and binary search to efficiently find the sub…
区域和检索 - 数组不可变
The Range Sum Query - Immutable problem involves implementing a data structure to handle range sum queries efficiently.
二维区域和检索 - 矩阵不可变
Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.
区域和检索 - 数组可修改
Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.
买卖股票的最佳时机含冷冻期
Maximize stock profit with cooldown restrictions using state transition dynamic programming to track buy, sell, and cool…
戳气球
Burst Balloons is a hard dynamic programming problem requiring careful state transitions to maximize coins collected eff…
超级丑数
Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …
计算右侧小于当前元素的个数
Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.
最大单词长度乘积
The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…
拼接最大数
Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.
零钱兑换
Find the minimum number of coins needed to reach a target amount using dynamic programming state transitions efficiently…
摆动排序 II
Rearrange an array in a way that every odd-indexed element is greater than its adjacent even-indexed elements.
区间和的个数
Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…
矩阵中的最长递增路径
Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.
按要求补齐数组
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…
路径交叉
Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.
回文对
Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.
前 K 个高频元素
Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.
两个数组的交集
Find the intersection of two arrays while ensuring unique elements using efficient array scanning and hash lookups.
两个数组的交集 II
Find the intersection of two arrays, accounting for multiple occurrences of the same number.
俄罗斯套娃信封问题
Russian Doll Envelopes is a dynamic programming problem that involves finding the longest chain of envelopes that can be…
矩形区域不超过 K 的最大数值和
Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…
最大整除子集
Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…
查找和最小的 K 对数字
Find K Pairs with Smallest Sums combines arrays and heap usage to select the smallest sum pairs efficiently.
摆动序列
Find the longest wiggle subsequence in an integer array using state transition dynamic programming with greedy optimizat…
组合总和 Ⅳ
Combination Sum IV asks to find the number of combinations that sum to a given target using elements from an array.
有序矩阵中第 K 小的元素
Find the kth smallest element in a sorted n x n matrix using efficient binary search or heap strategies for optimized me…
O(1) 时间插入、删除和获取随机元素
Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.
O(1) 时间插入、删除和获取随机元素 - 允许重复
This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…
打乱数组
Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…
完美矩形
Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…
UTF-8 编码验证
Determine if an integer array represents valid UTF-8 encoding based on its byte sequences using bit manipulation.
旋转函数
Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.
除法求值
Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.
青蛙过河
Determine if a frog can cross a river using jumps constrained by previous step sizes in a dynamic programming state tran…
根据身高重建队列
Reconstruct a queue based on the given heights and the number of taller people in front, using sorting and binary indexe…
接雨水 II
Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.
分割数组的最大值
Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…
等差数列划分
Count the number of arithmetic subarrays in a given integer array using dynamic programming.
第三大的数
Find the third distinct maximum number in an array using array traversal and sorting techniques, handling duplicates car…
分割等和子集
Determine if an array can be partitioned into two subsets with equal sum using dynamic programming techniques.
太平洋大西洋水流问题
Find all cells on an island where water can flow to both the Pacific and Atlantic oceans using DFS or BFS.
棋盘上的战舰
Count the number of non-overlapping battleships on a 2D board using array traversal and depth-first search patterns effi…
数组中两个数的最大异或值
Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.
建立四叉树
Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.
无重叠区间
Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…
数组中重复的数据
Find all integers that appear twice in an array with O(n) time and constant space complexity.
等差数列划分 II - 子序列
Count all arithmetic subsequences in an array using dynamic programming with precise state transitions for correctness.
回旋镖的数量
Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.
找到所有数组中消失的数字
Identify all missing numbers in an array using efficient scanning and hash-based lookup for optimal performance.
用最少数量的箭引爆气球
Find the minimum number of arrows needed to burst all balloons by considering greedy choice and invariant validation.
最小操作次数使数组元素相等
Compute the fewest steps to make all elements equal by incrementing n-1 array items, applying array and math reasoning.
四数相加 II
Count all quadruples from four integer arrays that sum to zero using efficient array scanning and hash table lookups.
分发饼干
Maximize content children by assigning at most one cookie per child using two-pointer scanning and greedy sorting techni…
132 模式
Identify whether a given integer array contains a 132 pattern subsequence using efficient stack and search techniques.
环形数组是否存在循环
Detect whether a circular array contains a loop of consistent direction using efficient array scanning and hash lookup t…
最小操作次数使数组元素相等 II
Find the minimum moves to equalize all array elements using increments or decrements with array and math techniques.
岛屿的周长
Determine the perimeter of an island in a grid of land and water cells using DFS or BFS.
连接词
Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …
火柴拼正方形
The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…
一和零
Solve the Ones and Zeroes problem using dynamic programming with state transition, focusing on array and string manipula…
供暖器
Determine the minimum heater radius to cover all houses using a binary search over potential radius values efficiently.
汉明距离总和
Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.
滑动窗口中位数
Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…
最大连续 1 的个数
Find the maximum sequence of consecutive 1s in a binary array using an efficient array-driven scanning approach.
预测赢家
Predict the Winner involves two players taking turns to maximize their score by picking from either end of an array, opt…
非递减子序列
Return all possible non-decreasing subsequences with at least two elements from the input array, nums.
翻转对
Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.
目标和
Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…
提莫攻击
Compute the total poisoned time Ashe experiences from Teemo's attacks using an array-based simulation approach efficient…
下一个更大元素 I
Find the next greater element for each number in nums1 from the nums2 array using an optimized approach.
非重叠矩形中的随机点
Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.
对角线遍历
Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.
键盘行
Identify all words from a list that can be typed using letters from only one row of a standard American keyboard.
IPO
Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…
下一个更大元素 II
Solve the Next Greater Element II problem by using a stack-based state management approach for circular arrays.
相对名次
Solve Relative Ranks by sorting scores with original indices, then writing medal labels or numeric places back in answer…
超级洗衣机
Calculate the minimum moves to balance dresses across washing machines using a greedy strategy and invariant validation …
零钱兑换 II
Calculate the number of unique coin combinations to reach a target amount using state transition dynamic programming eff…
最长特殊序列 II
Find the longest string in an array that is not a subsequence of any other string, using array scanning and hash checks …
连续的子数组和
Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.
通过删除字母匹配到字典里最长单词
Find the longest word in the dictionary that can be formed by deleting characters from a string, using two-pointer scann…
连续数组
Find the maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…
优美的排列
The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…
按权重随机选择
Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…
扫雷游戏
Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…
数组中的 k-diff 数对
Solve K-diff Pairs in an Array by counting unique differences with a hash map or sorted two-pointer sweep.
最小时间差
Calculate the smallest time difference between clock points using array manipulation and mathematical conversions effici…
有序数组中的单一元素
Find the single non-duplicate element in a sorted array where every other element appears exactly twice.
01 矩阵
The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…
移除盒子
Maximize points by strategically removing contiguous same-colored boxes using state transition dynamic programming and m…
最优除法
Maximize the value of an expression by optimally placing parentheses for division operations.
砖墙
Solve the Brick Wall problem using array scanning and hash lookups to minimize crossed bricks from a vertical line.
和为 K 的子数组
Count the total number of contiguous subarrays in an integer array that sum exactly to a target value k using optimized …
数组拆分
Maximize the sum of minimums of n pairs in a 2n integer array using a greedy pairing strategy efficiently.
数组嵌套
Find the longest nested set in a permutation array using a depth-first traversal, handling cycles efficiently for medium…
重塑矩阵
Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…
分糖果
Maximize the number of different candies Alice can eat given a set of candies and constraints on quantity.
最短无序连续子数组
Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.
安装栅栏
Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.
最长和谐子序列
Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …
区间加法 II
Range Addition II requires counting maximum values in a matrix after incremental operations using array and math reasoni…
两个列表的最小索引总和
Find the common strings between two lists with the smallest index sum in this easy problem involving array scanning and …
种花问题
Determine if n new flowers can be planted in a flowerbed, ensuring no adjacent flowers using a greedy approach.
在系统中查找重复文件
Find and return duplicate files in the file system, grouping them by their paths and contents using an array scanning ap…
有效三角形的个数
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…
设计循环队列
Design a circular queue that allows efficient FIFO operations using linked-list pointer manipulation to optimize space u…
数组列表中的最大距离
Maximum Distance in Arrays uses a greedy running minimum and maximum from previous arrays to validate cross array distan…
三个数的最大乘积
Find three numbers in an array whose product is the largest using sorting and careful handling of negative values.
课程表 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…
函数的独占时间
Solve the 'Exclusive Time of Functions' problem using stack-based state management for accurate function execution time …
大礼包
Minimize the cost of purchasing items using available special offers with state transition dynamic programming.
设计循环双端队列
Design and implement a circular deque using linked-list pointer manipulation, ensuring efficient insertion and deletion …
子数组最大平均数 I
Find the maximum average of any contiguous subarray of length k in a given integer array using a sliding window approach…
错误的集合
Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…
最长数对链
Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…
单词替换
Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…
最大二叉树
Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …
找到 K 个最接近的元素
Identify the k integers closest to a target x in a sorted array using binary search and two-pointer strategies efficient…
分割数组为连续子序列
Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.
图片平滑器
Apply a 3x3 smoothing filter to a matrix, rounding down each cell average including surrounding neighbors for accurate r…
非递减数列
Check if an array can become non-decreasing by modifying at most one element using an array-driven solution strategy.
优美的排列 II
Construct a beautiful arrangement of integers from 1 to n with k distinct integers, optimizing for time and space effici…
最长递增子序列的个数
This problem challenges you to find the number of longest increasing subsequences in a given array of integers.
最长连续递增序列
Find the length of the longest continuous increasing subsequence in an unsorted integer array using an array-driven solu…
为高尔夫比赛砍树
Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…
24 点游戏
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
棒球比赛
Simulate baseball score operations using a stack-based approach to compute the final score after all operations.
三个无重叠子数组的最大和
Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.
员工的重要性
Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…
贴纸拼词
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
前K个高频单词
Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…
岛屿的最大面积
Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.
数组的度
Find the shortest subarray with the same degree as the given array using efficient array scanning and hash lookups.
划分为k个相等的子集
Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…
掉落的方块
Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…
二分查找
Solve the Binary Search problem by finding the index of a target value in a sorted array with O(log n) complexity.
设计哈希集合
Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…
设计哈希映射
Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…
黑名单中的随机数
Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…
乘积小于 K 的子数组
Count subarrays with a product strictly less than a given value k using efficient algorithms like binary search and slid…
买卖股票的最佳时机含手续费
Maximize stock trading profits accounting for per-transaction fees using state transition dynamic programming and greedy…
1 比特与 2 比特字符
Determine whether the last character in a binary array represents a one-bit character or a two-bit character.
最长重复子数组
Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.
找出第 K 小的数对距离
Solve Find K-th Smallest Pair Distance by sorting nums, then binary searching the distance and counting valid pairs with…
词典中最长的单词
Find the longest word in a dictionary that can be built one character at a time from other words in the dictionary.
账户合并
Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…
删除注释
Remove comments from a given C++ program source array, handling line and block comments.
寻找数组的中心下标
Find the pivot index in an array where the sums of elements on both sides are equal using array and prefix sum technique…
我的日程安排表 I
Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …
我的日程安排表 II
Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…
图像渲染
Flood Fill is an array and DFS problem where you change connected pixels to a target color efficiently using recursion o…
小行星碰撞
Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…
每日温度
In the Daily Temperatures problem, you need to find out how many days to wait for a warmer temperature based on given da…
删除并获得点数
Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…
摘樱桃
Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…
寻找比目标字母大的最小字母
Locate the smallest character in a sorted array that is strictly greater than a given target using efficient binary sear…
前缀和后缀搜索
Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.
使用最小花费爬楼梯
Compute the minimum cost to reach the top of a staircase using dynamic programming and step-by-step state transitions ef…
至少是其他数字两倍的最大数
Determine if the largest number in the array is at least twice as large as every other element, and return its index or …
最短补全词
Find the shortest word that completes the license plate by matching all required letters, considering frequency and case…
隔离病毒
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
打开转盘锁
Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.
设置交集大小至少为2
Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.
最大加号标志
Find the largest axis-aligned plus sign in a binary grid with some mines using dynamic programming.
托普利茨矩阵
Determine if a given matrix is a Toeplitz matrix by checking diagonal consistency.
最多能完成排序的块 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…
滑动谜题
Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …
全局倒置与局部倒置
Determine if every global inversion in a permutation array is also a local inversion using array and math logic efficien…
水位上升的泳池中游泳
Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.
森林中的兔子
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
变为棋盘
Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.
第 K 个最小的质数分数
Find the k-th smallest fraction from a sorted array of unique primes using a binary search over the answer space.
逃脱阻碍者
Escape The Ghosts tests your ability to analyze movements in an infinite grid while racing against ghost positions using…
匹配子序列的单词数
Given a string s and a list of words, count how many words are subsequences of s using efficient array scanning and hash…
有效的井字游戏
Verify if a given Tic-Tac-Toe board can represent a valid game state during a valid sequence of moves.
区间子数组个数
Count the number of contiguous subarrays with a bounded maximum value using a two-pointer approach.
得分最高的最小轮调
Find the smallest rotation index with the highest score using array and prefix sum techniques.
使序列递增的最小交换次数
This problem involves finding the minimum number of swaps needed to make two sequences strictly increasing using dynamic…
打砖块
Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.
唯一摩尔斯密码词
Determine how many unique Morse code transformations can be generated from a list of words using a hash table and array …
数组的均值分割
Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…
写字符串需要的行数
Calculate how many lines are needed to write a string given individual letter widths, constrained to 100 pixels per line…
保持城市天际线
Maximize building heights in a city grid without changing the skyline, using greedy selection constrained by row and col…
情感丰富的文字
Expressive Words challenges you to determine if a word can be transformed into a given string by extending groups of rep…
黑板异或游戏
The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…
子域名访问计数
The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…
最大三角形面积
Find the area of the largest triangle formed by three distinct points on a 2D plane.
最大平均值和的分组
Maximize the sum of averages by partitioning an integer array into at most k contiguous subarrays using dynamic programm…
公交路线
Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.
链表组件
Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…
最常见的单词
Find the most frequent non-banned word in a paragraph, excluding punctuation, using an efficient array scan and hash tab…
单词的压缩编码
Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…
字符的最短距离
Compute the minimum distance from each character in a string to a target character using efficient scanning techniques.
翻转卡片游戏
The Card Flipping Game problem asks for the smallest integer that can be facing down but not up after flipping cards.
带因子的二叉树
Given an array of integers, find how many binary trees can be formed such that non-leaf nodes' values are the product of…
适龄的朋友
The Friends Of Appropriate Ages problem involves counting valid friend requests between people based on their ages with …
安排工作以达到最大收益
Assign workers to jobs maximizing total profit using difficulty, profit, and worker arrays efficiently with binary searc…
最大人工岛
Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…
翻转图像
Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.
字符串中的查找与替换
This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …
图像重叠
Image Overlap requires calculating the overlap between two binary matrices by translating one image over the other.
相似字符串组
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
矩阵中的幻方
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
猜猜这个单词
Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…
数组中的最长山脉
Find the length of the longest subarray forming a mountain pattern using state transitions and two-pointer logic efficie…
一手顺子
Check if a hand of cards can be rearranged into groups of consecutive values.
字母移位
Given a string and a shift array, shift the first i+1 letters of the string as specified in the array.
到最近的人的最大距离
Determine the seat placement that maximizes distance to the nearest person using a linear array scan strategy efficientl…
矩形面积 II
The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.
喧闹和富有
Determine the quietest person richer than each individual using graph indegree analysis and topological ordering techniq…
山脉数组的峰顶索引
Find the peak index in a mountain array using binary search for efficient O(log n) time complexity.
车队
The Car Fleet problem asks how many car fleets will reach a target given their starting positions and speeds, considerin…
雇佣 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.
和至少为 K 的最短子数组
Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.
获取所有钥匙的最短路径
Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.
转置矩阵
Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.
优势洗牌
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 length of the longest Fibonacci-like subsequence from a strictly increasing array of integers.
模拟行走机器人
The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…
爱吃香蕉的珂珂
Koko Eating Bananas challenges you to find the minimum eating speed to finish piles of bananas in a given time using bin…
石子游戏
Stone Game is a dynamic programming problem where players alternate taking stones from piles to maximize their score.
盈利计划
Given a group of members and a list of crimes, count the profitable schemes that meet the profit and group constraints.
救生艇
Find the minimum number of boats required to save all people, using a two-pointer approach for efficient pairing.
三维形体投影面积
Calculate the projection area of a 3D shape defined by a grid of towers with varying heights.
螺旋矩阵 III
Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…
公平的糖果交换
Determine which single candy box Alice and Bob should swap to equalize their total candies using array scanning and hash…
根据前序和后序遍历构造二叉树
Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.
查找和替换模式
Identify all words matching a given pattern by checking consistent letter mappings using hash tables and array scanning …
子序列宽度之和
Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.
三维形体的表面积
Solve the Surface Area of 3D Shapes problem using array manipulation and mathematical formulas to calculate surface area…
特殊等价字符串组
Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.
单调数列
Determine if an integer array is entirely monotone increasing or decreasing using a clear array-driven approach.
子数组按位或操作
Compute the number of unique bitwise OR values from all non-empty subarrays using dynamic state transitions efficiently.
RLE 迭代器
Design an efficient iterator for a run-length encoded array, handling large counts and sequential access correctly every…
最大为 N 的数字组合
The 'Numbers At Most N Given Digit Set' problem requires calculating how many numbers can be formed using a given digit …
水果成篮
The Fruit Into Baskets problem requires finding the maximum number of fruits you can pick from a row of trees under spec…
按奇偶排序数组
Reorder an integer array so all even numbers come before odd numbers using a precise two-pointer scanning method.
子数组的最小值之和
Calculate the sum of minimum values across all subarrays of a given array modulo 10^9 + 7.
最小差值 I
Find the smallest score of an array after applying an operation to each element within a given range.
蛇梯棋
Solve the Snakes and Ladders problem using a BFS strategy to efficiently navigate the board and reach the final square.
最小差值 II
Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…
在线选举
Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…
排序数组
Sort an array using an optimal algorithm, focusing on time and space complexity considerations.
卡牌分组
Solve the problem of determining if a deck can be partitioned into groups with equal occurrences of card values.
分割数组
Partition the array into two subarrays such that the left contains the smallest possible elements and the right contains…
单词子集
Word Subsets is solved by merging words2 into one max-frequency requirement, then scanning words1 against that fixed let…
环形子数组的最大和
Find the maximum sum of a circular subarray using state transition dynamic programming, optimizing for wraparound cases …
按奇偶排序数组 II
Sort an array where even numbers appear at even indices and odd numbers appear at odd indices using two-pointer scanning…
三数之和的多种可能
Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…
尽量减少恶意软件的传播
Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.
三等分
Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…
尽量减少恶意软件的传播 II
Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.
独特的电子邮件地址
Identify the count of unique email addresses by normalizing local names and using hash-based lookups efficiently.
和相同的二元子数组
Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…
下降路径最小和
Minimum Falling Path Sum is a matrix dynamic programming problem where each cell depends on three reachable cells above …
漂亮数组
Beautiful Array builds a valid permutation by recursively separating odd and even positions so no middle-average triple …
最短的桥
Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.
重新排列日志文件
Reorder Data in Log Files requires sorting letter-logs lexicographically while keeping digit-logs in original order for …
最小面积矩形
Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.
有效的山脉数组
The 'Valid Mountain Array' problem requires determining if an array meets the conditions of a valid mountain array using…
增减字符串匹配
Reconstruct a permutation from a DI string using two-pointer scanning, carefully tracking the increasing and decreasing …
最短超级串
This problem requires constructing the shortest string containing all input words using state transition dynamic program…
删列造序
The 'Delete Columns to Make Sorted' problem asks to remove unsorted columns from a string array, ensuring all columns ar…
使数组唯一的最小增量
This problem challenges you to find the minimum moves to make all elements in an array unique by incrementing elements.
验证栈序列
Determine if a sequence of push and pop operations can produce the given popped array using a stack-based state approach…
令牌放置
Maximize your score in the Bag of Tokens problem by strategically playing tokens with two-pointer scanning and greedy te…
给定数字能组成的最大时间
Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.
按递增顺序显示卡牌
Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.
按公因数计算最大组件大小
Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …
验证外星语词典
Verify if a sequence of words is sorted according to an alien language's custom alphabet order using array scanning and …
二倍数对数组
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…
最高的广告牌
Solve the Tallest Billboard problem by using dynamic programming to find the maximum equal height for two disjoint rod s…
N 天后的牢房
Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…
由斜杠划分区域
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
删列造序 III
The problem requires minimizing deletions to ensure all strings are lexicographically sorted. Use dynamic programming fo…
在长度 2N 的数组中找出重复 N 次的元素
Find the element that is repeated exactly N times in a 2N-sized array using array scanning and hash lookups.
最大宽度坡
Find the maximum width of a ramp where nums[i] <= nums[j] for i < j using a two-pointer approach.
最小面积矩形 II
Find the minimum area rectangle from given points in the X-Y plane, with sides not necessarily parallel to the axes.
元音拼写检查器
Implement a spellchecker that matches queries to a wordlist using exact, case-insensitive, and vowel-error rules efficie…
煎饼排序
Sort an array using pancake flips, leveraging two-pointer scanning and invariant tracking to iteratively position the la…
最接近原点的 K 个点
Find the k closest points to the origin in a 2D plane using array operations and Euclidean distance calculations efficie…
和可被 K 整除的子数组
Count the number of subarrays whose sum is divisible by a given integer k using array scanning and hash lookup.
奇偶跳
Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…
三角形的最大周长
Given an integer array, find the largest perimeter of a triangle formed from three of these lengths.
有序数组的平方
The problem involves squaring elements of a sorted array and returning the squares in non-decreasing order.
最长湍流子数组
Find the length of the longest subarray where element comparisons alternate, using state transition dynamic programming …
不同路径 III
Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…
按位与为零的三元组
Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…
最低票价
Solve the Minimum Cost For Tickets problem using state transition dynamic programming for optimal travel ticket purchase…
查询后的偶数和
Efficiently update an integer array based on queries and compute the sum of even numbers after each modification using s…
区间列表的交集
This problem requires finding the intersection of two lists of intervals using a two-pointer technique with invariant tr…
数组形式的整数加法
Compute the sum of an integer and a number represented as an array, efficiently handling digit carries and array travers…
等式方程的可满足性
Determine if it's possible to assign values to variables such that all equations are satisfied based on equality and ine…
K 个不同整数的子数组
Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.
腐烂的橘子
Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.
K 连续位的最小翻转次数
Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…
平方数组的数目
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
找到小镇的法官
Find the Town Judge is an easy LeetCode problem that challenges you to identify a town judge from trust relationships us…
可以被一步捕获的棋子数
This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…
合并石头的最低成本
Minimize the cost to merge stones with k consecutive piles using dynamic programming to achieve the optimal solution.
网格照明
Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …
查找共用字符
Return an array of common characters from all strings in the given list of words, including duplicates.
最大连续1的个数 III
Find the longest consecutive ones in a binary array by optimally flipping at most k zeros using sliding window technique…
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.
前序遍历构造二叉搜索树
Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.
总持续时间可被 60 整除的歌曲
Calculate the number of song pairs whose total durations sum to a multiple of 60 using array scanning and hash lookups.
在 D 天内送达包裹的能力
Find the minimum ship capacity needed to ship all packages within D days, ensuring the cargo is shipped in the given ord…
将数组分成和相等的三个部分
Determine if an array can be partitioned into three non-empty parts with equal sum using greedy choice and validation.
最佳观光组合
Compute the maximum sightseeing score efficiently using state transition dynamic programming and single-pass array itera…
可被 5 整除的二进制前缀
Determine which binary prefixes of a given array are divisible by 5 using bit manipulation for efficient checks.
链表中的下一个更大节点
Find the next greater value for each node in a linked list using monotonic stack techniques for efficient traversal.
飞地的数量
This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…
驼峰式匹配
Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…
视频拼接
Solve the "Video Stitching" problem using state transition dynamic programming to cover a sporting event with minimum cl…
最长等差数列
Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.
两地调度
Two City Scheduling requires selecting optimal city assignments for 2n people to minimize total travel costs efficiently…
距离顺序排列矩阵单元格
Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…
两个无重叠子数组的最大和
Find the maximum sum of two non-overlapping subarrays by efficiently using state transition dynamic programming.
字符流
Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…
边界着色
Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …
不相交的线
The Uncrossed Lines problem involves finding the maximum number of non-intersecting lines that can be drawn between two …
逃离大迷宫
The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…
有效的回旋镖
Determine if three points on a 2D plane form a boomerang, based on distinctness and non-collinearity.
多边形三角剖分的最低得分
Compute the minimum total score to triangulate a convex polygon using state transition dynamic programming on vertex val…
移动石子直到连续 II
Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…
分隔数组以得到最大和
Partition an array into subarrays of length at most k, replacing each with its maximum to maximize total sum efficiently…
最后一块石头的重量
In the 'Last Stone Weight' problem, we smash the two heaviest stones until one remains, using heaps or sorting.
最长字符串链
Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…
最后一块石头的重量 II
In the 'Last Stone Weight II' problem, you need to find the minimal possible stone weight after a series of smashes usin…
高度检查器
Determine how many students are out of place in a line by comparing their heights to the sorted expected order efficient…
爱生气的书店老板
Maximize satisfied customers in a bookstore by strategically suppressing the owner's grumpy minutes using a sliding wind…
交换一次的先前排列
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…
按列翻转得到最大值等行数
Maximize the number of equal rows in a binary matrix by flipping any number of columns.
负二进制数相加
Add two numbers represented in negabinary format and return the result in the same format.
元素和为目标值的子矩阵数量
Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…
复写零
Duplicate each zero in a fixed-length array in place, shifting elements right using a two-pointer scanning approach effi…
受标签影响的最大值
Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.
二进制矩阵中的最短路径
Find the shortest clear path in a binary matrix using BFS, carefully handling obstacles and diagonal movements for effic…
大样本统计
Calculate minimum, maximum, mean, median, and mode from a large sample represented by an array of counts.
拼车
Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…
山脉数组中查找目标值
Find in Mountain Array requires locating a target using binary search over a peak-structured array efficiently in intera…
填充书架
Determine the minimum total height of a bookcase by placing books in order using state transition dynamic programming.
航班预订统计
Solve Corporate Flight Bookings by marking range changes once, then building final seat totals with a single prefix sum …
删点成林
Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.
数组的相对排序
Sort arr1 by the relative order of arr2, with remaining elements placed in ascending order.
表现良好的最长时间段
The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…
最小的必要团队
Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…
等价多米诺骨牌对的数量
Count all pairs of dominoes that are equivalent by scanning the array and using a hash table for fast lookup.
叶值的最小代价生成树
Compute the minimum sum of non-leaf nodes in a binary tree formed from array leaves using dynamic programming efficientl…
绝对值表达式的最大值
Calculate the largest sum of absolute differences across two arrays and their indices using an efficient pattern-based a…
最大的以 1 为边界的正方形
Find the largest square of 1s with 1s on its borders in a binary grid using dynamic programming.
石子游戏 II
Stone Game II is a dynamic programming problem where Alice and Bob alternate taking stones from piles to maximize their …
递减元素使数组呈锯齿状
Transform any integer array into a zigzag pattern with minimal decrements using a targeted greedy approach and invariant…
快照数组
Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…
子数组中占绝大多数的元素
Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.
拼写单词
Compute the total length of words that can be fully constructed from given characters using array scanning and hash mapp…
地图分析
Find the farthest water cell from land in a grid and return the Manhattan distance using state transition dynamic progra…
查询无效交易
Detect invalid transactions by scanning arrays and cross-checking with hash tables for time, amount, and city conflicts …
比较字符串最小字母出现频次
Compare Strings by Frequency of the Smallest Character requires counting minimal character frequencies in words and quer…
构建回文串检测
Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.
猜字谜
Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…
公交站间的距离
Compute the minimal distance between two bus stops on a circular route using an array-driven solution approach.
删除一次得到子数组最大和
Find the maximum sum of a subarray with at most one deletion in this dynamic programming problem.
使数组严格递增
Determine the minimum operations to transform arr1 into a strictly increasing sequence using values from arr2 efficientl…
K 次串联后最大子数组之和
Solve the K-Concatenation Maximum Sum problem using dynamic programming and optimal sub-array sum calculation.
最小绝对差
Find all pairs with the minimum absolute difference between two elements in an array, and return them in ascending order…
交换字符串中的元素
Find the lexicographically smallest string by swapping characters in given pairs of indices.
独一无二的出现次数
Determine if each integer in an array occurs a unique number of times using efficient hash-based counting and verificati…
穿过迷宫的最少移动次数
Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.
玩筹码
Compute the minimum cost to move all chips to one position using parity-based greedy moves efficiently.
最长定差子序列
Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.
黄金矿工
Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.
可以攻击国王的皇后
Identify all black queens on an 8x8 chessboard that can attack the white king using array and matrix simulation techniqu…
掷骰子模拟
Calculate all valid sequences of n dice rolls with consecutive roll constraints using state transition dynamic programmi…
最大相等频率
Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…
缀点成线
Determine if a series of coordinates form a straight line on a 2D plane using geometry and mathematical principles.
删除子文件夹
Remove sub-folders in a filesystem by filtering out folders nested inside other folders.
规划兼职工作
Compute the maximum profit from non-overlapping jobs using state transition dynamic programming with sorted arrays and b…
串联字符串的最大长度
Find the maximum length of a concatenated string from an array with all unique characters using backtracking search with…
统计「优美子数组」
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
检查「好数组」
Determine if a given array of positive integers can generate 1 using integer multiples of any subset, leveraging number …
奇数值单元格的数目
This problem involves updating a matrix based on given indices and counting cells with odd values afterward.
重构 2 行二进制矩阵
Reconstruct a 2-row binary matrix by distributing column sums while respecting upper and lower row limits using greedy p…
统计封闭岛屿的数目
Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.
得分最高的单词集合
Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…
二维网格迁移
Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.
可被三整除的最大和
Find the maximum sum divisible by three from a given array using dynamic programming and state transition.
推箱子
Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…
访问所有点的最小时间
Calculate the minimum seconds required to visit all given 2D points in order using optimal diagonal or straight moves.
统计参与通信的服务器
Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…
搜索推荐系统
Design a search suggestion system that provides the top three lexicographically smallest products matching a search word…
找出井字棋的获胜者
Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…
统计全为 1 的正方形子矩阵
Count the number of square submatrices with all ones in a given binary matrix using dynamic programming.
用户分组
Organize people into groups based on their specified group sizes using array scanning and hash table bucketing efficient…
使结果不超过阈值的最小除数
Find the smallest divisor such that the sum of all divided array elements is less than or equal to the threshold.
转化为全零矩阵的最少反转次数
Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…
有序数组中出现次数超过25%的元素
Identify the integer occurring more than 25% in a sorted array using a precise array-driven search strategy for efficien…
删除被覆盖区间
Remove all intervals fully covered by another using sorting and linear traversal, counting only distinct remaining inter…
下降路径最小和 II
Find the minimum sum of a falling path in a square matrix using dynamic programming while avoiding same-column selection…
元素和小于等于阈值的正方形的最大边长
This problem challenges you to find the largest square in a matrix with a sum below a given threshold using binary searc…
网格中的最短路径
Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.
统计位数为偶数的数字
Count the integers in an array that have an even number of digits using a direct array traversal with digit math.
划分数组为连续数字的集合
Determine if an integer array can be partitioned into sets of k consecutive numbers using array scanning and hash mappin…
你能从盒子里获得的最大糖果数
Collect maximum candies from boxes by exploring initially available boxes and using keys to unlock additional ones effic…
将每个元素替换为右侧最大元素
Replace every element in an array with the greatest element on its right side, and replace the last element with -1.
转变数组后最接近目标值的数组和
Find the integer that mutates all larger elements in an array to minimize the sum difference to a target efficiently.
最大得分的路径数目
Calculate the maximum score path and count all valid routes in a square board with obstacles using dynamic programming.
和为零的 N 个不同整数
Generate an array of n unique integers that sum to zero using a symmetric pairing strategy to ensure balance.
跳跃游戏 III
Jump Game III challenges you to determine if you can reach any zero in an array using jumps defined by array values, tes…
口算难题
Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.
子数组异或查询
Compute XOR results for multiple subarray queries using efficient prefix XOR to reduce repeated computation overhead in …
获取你好友已观看的视频
Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.
解压缩编码列表
Decompress a run-length encoded list by expanding each pair into repeated values based on frequency.
矩阵区域和
Compute a matrix where each cell contains the sum of all elements within k-distance blocks using prefix sums efficiently…
竖直打印单词
Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…
灌溉花园的最少水龙头数目
Determine the minimum number of taps to water an entire garden using state transition dynamic programming and interval c…
将矩阵按对角线排序
Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.
翻转子数组得到最大的数组值
Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.
数组序号转换
Transform the elements of an array into their ranks, where the rank represents the size order of the elements.
餐厅过滤器
Filter restaurants by vegan-friendly status, price, and distance, and sort them by rating and ID.
工作计划的最低难度
Schedule jobs into multiple days to minimize the difficulty of the schedule using dynamic programming and state transiti…
矩阵中战斗力最弱的 K 行
Find the k weakest rows in a binary matrix where rows contain soldiers and civilians, using sorting and binary search te…
数组大小减半
This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…
跳跃游戏 V
Jump Game V is a hard dynamic programming problem that focuses on maximizing jumps between indices in an array.
大小为 K 且平均值大于等于阈值的子数组数目
Given an array, find the number of sub-arrays of size k with an average greater than or equal to a given threshold.
跳跃游戏 IV
Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…
检查整数及其两倍数是否存在
Solve Check If N and Its Double Exist by scanning once and checking doubles or halves in a hash set.
参加考试的最大学生数
Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…
统计有序矩阵中的负数
Count Negative Numbers in a Sorted Matrix requires counting negative numbers in a matrix sorted in non-increasing order …
最后 K 个数的乘积
Design a data structure to efficiently return the product of the last k numbers in a dynamic integer stream using prefix…
最多可以参加的会议数目
Maximize the number of events you can attend given their start and end days using a greedy strategy.
多次求和构造目标数组
This problem requires constructing a target array from an array of ones, using multiple sum operations and a priority qu…
根据数字二进制下 1 的数目排序
Sort an array of integers by the number of 1's in their binary representation and then by their value in case of ties.
每隔 n 个顾客打折
Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …
形成三的最大倍数
Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…
有多少小于当前数字的数字
In this problem, you need to determine how many numbers are smaller than each element in an array, focusing on array sca…
通过投票对团队排名
Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…
使网格图至少有一条有效路径的最小代价
Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.
二进制字符串前缀一致的次数
Count how many times a 1-indexed binary string becomes prefix-aligned as bits are flipped sequentially using an array-dr…
矩阵中的幸运数
The Lucky Numbers in a Matrix problem involves finding elements that are the minimum in their row and maximum in their c…
设计一个支持增量操作的栈
Implement a stack that supports push, pop, and targeted increment operations efficiently using array-based state managem…
最大的团队表现值
Maximize the performance of a team by selecting up to k engineers with the highest performance based on speed and effici…
两个数组间的距离值
Calculate the distance value between two integer arrays by determining how many elements in arr1 don't have a close coun…
安排电影院座位
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.
按既定顺序创建目标数组
Learn how to efficiently create a target array by inserting elements at specified indices using array simulation techniq…
四因数
Compute the sum of all divisors for numbers in an array that have exactly four divisors using array and math techniques.
检查网格中是否存在有效路径
Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.
找出数组中的幸运数
Identify the largest lucky integer in an array by counting frequencies and comparing values with their occurrences effic…
统计作战单位数
Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…
做菜顺序
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.
石子游戏 III
Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.
数组中的字符串匹配
Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…
查询带键的排列
This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.
逐步求和得到正数的最小值
Find the minimum starting value to ensure the step-by-step sum of an array is always at least 1.
点菜展示表
Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…
可获得的最大点数
Maximize your score by selecting k cards from the beginning or end of the array using a sliding window approach.
对角线遍历 II
Traverse a jagged 2D array diagonally by grouping elements with equal row and column sums efficiently using sorting and …
带限制的子序列和
Solve the Constrained Subsequence Sum problem using dynamic programming, sliding window, and priority queues to maximize…
拥有最多糖果的孩子
Determine which kids, after receiving extra candies, will have the greatest number of candies in a group.
每个人戴不同帽子的方案数
Calculate all unique assignments of hats to people using state transition dynamic programming with bitmasking for collis…
旅行终点站
Find the destination city from a list of paths where each path connects two cities. The city with no outgoing path is th…
是否所有 1 都至少相隔 k 个元素
Check if all 1's in a binary array are at least k places away from each other.
绝对差不超过限制的最长连续子数组
Find the longest subarray with elements whose absolute difference is within a specified limit using a sliding window app…
有序矩阵中的第 k 个最小数组和
Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.
用栈操作构建数组
Simulate stack operations to match a target array while processing numbers from 1 to n.
形成两个异或相等数组的三元组数目
Efficiently count all triplets in an array where two subarrays formed by splitting have equal XOR using array scanning a…
切披萨的方案数
This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…
数位成本和为目标值的最大数字
Maximize the integer you can paint with given digit costs under a target sum, using dynamic programming to optimize the …
在既定时间做作业的学生人数
Count the number of students doing homework at a given time using an array-driven solution approach.
收藏清单
Identify people whose favorite companies lists are unique and not subsets of any other person's list using efficient arr…
圆形靶内的最大飞镖数量
Maximize the number of darts on a circular dartboard given dart positions and radius.
两个子序列的最大点积
Solve Max Dot Product of Two Subsequences with state transition dynamic programming that enforces a non-empty pairing de…
通过翻转子数组使两个数组相等
Solve Make Two Arrays Equal by Reversing Subarrays by checking whether target and arr contain the same values with match…
摘樱桃 II
Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…
数组中两元素的最大乘积
Find the maximum product of two elements in an array by carefully selecting indices and leveraging sorting for efficienc…
切割后面积最大的蛋糕
Maximize the area of a piece of cake after specified horizontal and vertical cuts using greedy algorithms and sorting.
两个盒子中球的颜色数相同的概率
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
重新排列数组
Shuffle the Array requires an efficient approach to rearrange elements using an array-driven solution strategy with two …
数组中的 k 个最强值
Identify the k strongest values in an array using two-pointer scanning and careful tracking of the array's centre value.
设计浏览器历史记录
Implement a browser history tracker with back, forward, and visit operations using linked-list pointer manipulation effi…
粉刷房子 III
Solve Paint House III using state transition dynamic programming to minimize painting costs while forming exact neighbor…
商品折扣后的最终价格
Calculate final prices with discounts applied in a shop using a stack-based state management approach to find the correc…
子矩形查询
Implement the SubrectangleQueries class to handle dynamic updates and value queries on a 2D rectangle.
找两个和为目标值且不重叠的子数组
Find two non-overlapping sub-arrays with a given target sum and return the minimal total length efficiently using array …
安排邮筒
Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…
一维数组的动态和
Calculate the running sum of a given 1D array by updating each element to the sum of itself and all previous elements.
不同整数的最少数目
Find the least number of unique integers after removing exactly k elements from an array using efficient frequency count…
制作 m 束花所需的最少天数
Determine the minimum number of days required to make m bouquets using k adjacent flowers efficiently with binary search…
保证文件名唯一
This problem requires creating unique folder names by appending suffixes to duplicate names using an array scanning and …
避免洪水泛滥
This problem asks you to avoid flooding by deciding when to dry lakes between rain events.
去掉最低工资和最高工资后的工资平均值
Calculate the average salary of employees, excluding the highest and lowest salaries, from an array of unique salaries.
删掉一个元素以后全为 1 的最长子数组
Solve LeetCode 1493 by tracking runs of 1s around one deletion using a tight sliding window or state transition DP.
检查数组对是否可以被 k 整除
Check if array pairs are divisible by k by pairing elements whose sums are divisible by k using array scanning and hash …
满足条件的子序列数目
Count all non-empty subsequences in an integer array where the sum of the minimum and maximum elements is at most a targ…
满足不等式的最大值
Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…
判断能否形成等差数列
Determine if a given array can be rearranged into a valid arithmetic progression using sorting and consecutive differenc…
所有蚂蚁掉下来前的最后一刻
This problem involves simulating ant movement on a plank to determine the last moment before all ants fall off.
统计全 1 子矩形
Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…
子数组和排序后的区间和
Compute the sum of sorted subarray sums efficiently using binary search over valid sum ranges and prefix sum accumulatio…
三次操作后最大值与最小值的最小差
Find the minimum difference between the largest and smallest values in an array after performing at most three moves.
好数对的数目
Count all index pairs in an array where elements match and the first index is smaller, using hash-based scanning efficie…
概率最大的路径
Find the path with the highest success probability in a graph from a start node to an end node, using edge probabilities…
服务中心的最佳位置
Find the optimal service center position in a city by minimizing the sum of Euclidean distances to all customers.
找到最接近目标值的函数值
In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.
和为奇数的子数组数目
Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.
形成目标数组的子数组最少增加次数
The problem asks for the minimum number of operations to transform an initial array of zeros into a target array using s…
重新排列字符串
Reorder characters in a string using a given indices array to reconstruct the intended output efficiently and correctly.
统计好三元组
Count Good Triplets requires identifying all triplets in an array that satisfy multiple absolute difference constraints …
找出数组游戏的赢家
Determine the integer that wins an array game by achieving k consecutive victories through simulated pairwise comparison…
排布二进制网格的最少交换次数
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 …
第 k 个缺失的正整数
Find the kth missing positive integer in a strictly increasing array using binary search over the answer space efficient…
和为目标值且不重叠的非空子数组的最大数目
Find the maximum number of non-overlapping subarrays that sum to a given target using efficient scanning and hash lookup…
切棍子的最小成本
Find the minimum cost to cut a stick into segments at specified positions using dynamic programming and sorting.
存在连续三个奇数的数组
Determine if an integer array contains three consecutive odd numbers using a direct array-driven solution strategy for f…
两球之间的磁力
Maximize the minimum magnetic force between balls by strategically placing them in baskets using binary search on positi…
得到目标数组的最少函数调用次数
Calculate the minimum number of modify calls needed to convert an all-zero array into a given target array using greedy …
二维网格图中探测环
Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.
圆形赛道上经过次数最多的扇区
Determine which sectors on a circular track are visited most frequently using array and simulation techniques efficientl…
你可以获得的最大硬币数目
Solve the Maximum Number of Coins You Can Get using greedy pile selection and invariant validation to maximize your coin…
查找大小为 M 的最新分组
Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…
石子游戏 V
In Stone Game V, Alice divides stones into rows to maximize her score, using a dynamic programming approach to try all d…
重复至少 K 次且长度为 M 的模式
Determine if a subarray of length m repeats k or more consecutive times in a given integer array efficiently.
乘积为正数的最长子数组长度
Given an array, find the maximum length of a subarray with a positive product using dynamic programming.
使陆地分离的最少天数
Find the minimum number of days to disconnect an island in a grid using depth-first search.
将子数组重新排序得到同一个二叉搜索树的方案数
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
矩阵对角线元素的和
Calculate the sum of both primary and secondary diagonals in a square matrix while avoiding double-counting overlaps.
删除最短的子数组使剩余数组有序
Find the shortest subarray to remove in order to make an array non-decreasing using binary search and two-pointer techni…
统计所有可行路径
This problem requires counting all possible routes between cities using fuel efficiently with state transition dynamic p…
数的平方等于两数乘积的方法数
Find the number of triplets where the square of a number equals the product of two others, utilizing array scanning and …
使绳子变成彩色的最短时间
Minimize the time Bob needs to remove balloons to make a rope colorful using dynamic programming with state transitions.
二进制矩阵中的特殊位置
Identify all special positions in a binary matrix where a 1 has no other 1s in its row or column, ensuring optimal array…
统计不开心的朋友
Determine the number of unhappy friends in paired arrangements using array-based simulation for preference violations.
连接所有点的最小费用
Min Cost to Connect All Points asks for the minimum cost to connect all points on a 2D plane, using manhattan distances …
所有奇数长度子数组的和
Calculate the sum of all odd-length subarrays in a given integer array using efficient array and math strategies.
所有排列中的最大和
Maximize the total sum of requests on nums by greedily assigning larger numbers to most frequently requested indices.
使数组和能被 P 整除
Determine the minimum-length subarray to remove so the remaining array sum is divisible by a given integer p efficiently…
奇怪的打印机 II
Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…
矩阵的最大非负积
Find the maximum non-negative product path in a matrix using dynamic programming and state transition.
连通两组点的最小成本
Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.
文件夹操作日志搜集器
Simulate folder navigation based on a list of operations to determine the current folder depth.
经营摩天轮的最大利润
Maximize the profit from operating a Centennial Wheel by determining the optimal number of rotations based on customer a…
最多可达成的换楼请求数目
Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.
警告一小时内使用相同员工卡大于等于三次的人
Solve LeetCode 1604 by grouping swipe times per employee, sorting each list, and scanning for any three within 60 minute…
给定行和列的和求可行矩阵
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…
特殊数组的特征值
Determine if an array has exactly x elements greater than or equal to x using binary search over the answer space.
可见点的最大数目
Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…
删除某些元素后的数组均值
Calculate the trimmed mean by removing the lowest and highest 5% of elements in an array using sorting for accuracy and …
网络信号最好的坐标
Determine the coordinate with the maximum network quality by summing signal strengths from all reachable towers efficien…
无矛盾的最佳球队
Find the highest score basketball team by choosing players without conflicts in age and score using dynamic programming.
带阈值的图连通性
In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…
按键持续时间最长的键
Determine which key had the longest press duration in a sequence using array indices and string mapping, resolving ties …
等差子数组
Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…
最小体力消耗路径
Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…
矩阵转换后的排名
Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…
按照频率将数组升序排序
Sort Array by Increasing Frequency requires counting each element and ordering them by frequency, breaking ties with des…
两点之间不包含任何点的最宽垂直区域
Find the maximum width of a vertical area between points with no points inside using array sorting efficiently.
通过给定词典构造目标字符串的方案数
Calculate the number of ways to form a target string using words of equal length via state transition dynamic programmin…
能否连接形成数组
Determine if an array can be formed by concatenating subarrays without reordering individual elements, using hash lookup…
可以到达的最远建筑
Furthest Building You Can Reach explores a greedy approach with heap-based optimization to find the maximum reachable bu…
第 K 条最小指令
Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…
获取生成数组中的最大值
Compute the maximum value in a generated array using defined recurrence rules, leveraging array simulation techniques ef…
销售价值减少的颜色球
Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.
通过指令创建有序数组
The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.
拆炸弹
Defuse the Bomb uses a sliding window to update a circular array based on a key, with efficient state updates.
到家的最少跳跃次数
Find the minimum number of jumps needed to reach a target position while avoiding forbidden positions.
分配重复整数
Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…
设计有序流
Design an Ordered Stream that returns values in increasing order based on unique integer IDs with efficient insertion an…
将 x 减到 0 的最小操作数
Find the minimum number of operations to reduce a value x to zero by removing elements from an array.
检查两个字符串数组是否相等
Determine if two string arrays form identical strings by concatenating elements in order, handling subtle array-length m…
生成平衡数组的方案数
Solve Ways to Make a Fair Array by tracking parity sums before and after each removal with prefix-sum style accounting.
完成所有任务的最少初始能量
Determine the minimum initial energy needed to finish all tasks using a greedy ordering based on required versus actual …
设计前中后队列
Implement a queue that efficiently handles push and pop operations at the front, middle, and back using pointer manipula…
得到山形数组的最少删除次数
Solve the problem of finding the minimum number of removals to make a given array a mountain array using dynamic program…
最富有客户的资产总量
Calculate the richest customer's wealth by summing the amounts in each customer's bank accounts in a matrix.
找出最具竞争力的子序列
Identify the lexicographically smallest subsequence of size k using stack-based greedy selection in array traversal.
使数组互补的最少操作次数
Find the minimum moves to make an array complementary by analyzing paired sums and using hash lookups for efficiency.
数组的最小偏移量
Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…
K 和数对的最大数目
Max Number of K-Sum Pairs is a problem involving counting disjoint pairs with a given sum k in an array.
最小不兼容性
Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.
统计一致字符串的数目
Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.
有序数组中差绝对值之和
Calculate the sum of absolute differences between each element and others in a sorted array efficiently.
石子游戏 VI
Determine the winner in Stone Game VI using a greedy strategy that accounts for each stone's dual value impact on Alice …
从仓库到码头运输箱子
Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…
石子游戏 VII
Maximize score difference in a two-player turn-based stone removal game using state transition dynamic programming.
堆叠长方体的最大高度
Maximize the height of stacked cuboids by strategically rotating and stacking them using dynamic programming.
删除子数组的最大得分
Maximize the score by erasing a subarray with unique elements in an array of integers.
跳跃游戏 VI
Jump Game VI challenges you to maximize your score while jumping through an array using state transition dynamic program…
检查边长度限制的路径是否存在
Solve the problem of checking if there exists a path between two nodes under edge length constraints using efficient tec…
无法吃午餐的学生数量
Simulate a queue of students with sandwich preferences and determine how many can't eat based on available sandwiches.
平均等待时间
Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…
得到连续 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.
球会落何处
Determine where each ball exits a diagonal board grid or if it gets stuck, using matrix simulation with careful traversa…
与数组中元素的最大异或值
Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…
卡车上的最大单元数
Maximize total units loaded on a truck by choosing boxes greedily based on highest units per box within truck capacity l…
大餐计数
Count Good Meals asks you to find pairs of food items with a sum of deliciousness equal to a power of two.
将数组分成三个子数组的方案数
The problem requires finding the number of ways to split an array into three subarrays where each split meets a certain …
得到子序列的最少操作次数
Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…
构建字典序最大的可行序列
Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…
解码异或后的数组
Recover the original integer array from its XOR-encoded version using direct bitwise manipulation and sequential reconst…
执行交换操作后的最小汉明距离
Solve Minimize Hamming Distance After Swap Operations by grouping swappable indices and matching value counts inside eac…
完成所有工作的最短时间
Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…
可以形成最大正方形的矩形数目
Determine how many rectangles can be trimmed to form the largest possible square using an array-driven solution strategy…
同积元组
Given an array of distinct integers, return the number of tuples where the product of two pairs is the same.
重新排列后的最大子矩阵
Rearrange columns of a binary matrix to find the largest submatrix of 1s.
猫和老鼠 II
Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…
找到最高海拔
Find the highest altitude after a series of altitude changes during a road trip using prefix sum technique.
需要教语言的最少人数
Minimize the number of users to teach a language that ensures all friends can communicate in a social network.
解码异或后的排列
Decode XORed Permutation uses prefix reconstruction with global XOR to recover the hidden odd-length permutation in line…
生成乘积数组的方案数
Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…
找出第 K 大的异或坐标值
Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…
从相邻元素对还原数组
Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…
你能在你最喜欢的那天吃到你最喜欢的糖果吗?
Determine if you can eat a candy of your favorite type on a specific day, given daily limits and candy availability.
唯一元素的和
Given an array, find the sum of all its unique elements by identifying those that appear only once.
任意子数组和的绝对值的最大值
Solve for the maximum absolute sum of any subarray using dynamic programming and understanding state transitions.
最多可以参加的会议数目 II
Determine the maximum sum of event values you can collect by attending at most k non-overlapping events using DP.
检查数组是否经排序和轮转得到
Determine if a given integer array is sorted in non-decreasing order and then rotated, handling duplicates correctly.
最接近目标值的子序列和
Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…
袋子里最少数目的球
Find the minimum penalty (maximum balls in a bag) after performing up to maxOperations to split bags of balls.
通过连接另一个数组的子数组得到一个数组
Determine if you can sequentially select disjoint subarrays from nums matching each group in order using two-pointer sca…
地图中的最高点
Solve the Map of Highest Peak problem using breadth-first search to assign heights based on proximity to water cells.
互质树
Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…
移动所有球到每个盒子所需的最小操作数
Solve the problem of finding the minimum operations to move balls to each box using an efficient approach with arrays an…
执行乘法运算的最大分数
Solve the Maximum Score from Performing Multiplication Operations problem using dynamic programming and state transition…
统计匹配检索规则的物品数量
Count Items Matching a Rule is an easy problem that tests array and string manipulation with conditions based on specifi…
最接近目标价格的甜点成本
Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…
通过最少操作次数使数组的和相等
Solve the problem of balancing the sums of two integer arrays with minimal operations, using array scanning and hash loo…
车队 II
Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…
找到最近的有相同 X 或 Y 坐标的点
Find the nearest point with the same x or y coordinate using Manhattan distance. Return its index or -1 if none exists.
统计点对的数目
Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.
构成特定和需要添加的最少元素
Compute the gap between current sum and goal, then greedily cover it with limit-sized additions to get the minimum count…
使所有区间的异或结果为零
Determine the minimum changes needed in an array so all size-k segments XOR to zero using DP and bit manipulation.
最大平均通过率
Maximize the average pass ratio by assigning extra guaranteed-passing students using a greedy heap strategy for optimal …
好子数组的最大分数
Maximize the score of a good subarray using binary search to explore the valid answer space with a focus on two-pointer …
你能构造出连续值的最大数目
Find the maximum number of consecutive integer values starting from zero that can be formed using your coins array.
N 次操作后的最大分数和
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
最大升序子数组和
Solve Maximum Ascending Subarray Sum by scanning once, extending rising runs, and resetting the running sum at each drop…
积压订单中的订单总数
Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …
统计异或值在范围内的数对有多少
Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …
还原排列的最少操作步数
Find the minimum number of operations to reinitialize a permutation of size n using specific operations.
替换字符串中的括号内容
Quickly evaluate a string with bracketed keys using array scanning and hash table lookups for efficient replacements.
句子相似性 III
Sentence Similarity III asks if one sentence can be transformed into another by inserting a sentence inside it.
统计一个数组中好对子的数目
Count Nice Pairs in an Array requires efficiently pairing numbers where nums[i] + rev(nums[j]) equals nums[j] + rev(nums…
得到新鲜甜甜圈的最多组数
Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…
截断句子
Truncate a sentence to contain only the first k words by converting it into an array of words.
查找用户活跃分钟数
This problem requires counting unique minutes of user activity on LeetCode based on a series of logs and an integer k.
绝对差值和
Minimize the absolute sum difference between two integer arrays by replacing at most one element from the first array.
序列中不同最大公约数的数目
Given an array of positive integers, find the number of different subsequences' GCDs.
数组元素积的符号
Determine the sign of a product from an integer array using a single pass without computing the full product.
找出游戏的获胜者
Find the winner of a circular game by simulating the elimination process with a queue-driven approach.
最少侧跳次数
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…
统计一个圆中点的数目
Determine how many 2D points lie within multiple circles using array iteration and Euclidean distance calculations effic…
每个查询的最大异或值
Find the maximum XOR for each query based on a sorted array and bit manipulation.
雪糕的最大数量
Maximize the number of ice cream bars a boy can buy by applying a greedy choice strategy based on cost sorting.
单线程 CPU
Simulate task processing with a single-threaded CPU by sorting and prioritizing tasks based on arrival and processing ti…
所有数对按位与结果的异或和
Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.
最高频元素的频数
Maximize the frequency of an element in an array by incrementing at most `k` elements. Use binary search and greedy tech…
最高建筑高度
Find the maximum building height in a city given height restrictions for specific buildings.
减小和重新排列数组后的最大元素
Determine the maximum value in an array after decreasing elements and rearranging using a greedy invariant approach.
最近的房间
Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…
到目标元素的最小距离
Solve Minimum Distance to the Target Element by scanning the array and tracking the smallest distance from start.
包含每个查询的最小区间
Find the smallest interval containing each query efficiently using binary search.
人口最多的年份
Find the earliest year with the highest population using an array plus counting approach.
下标对中的最大距离
Find the maximum distance between a pair of values in two non-increasing integer arrays using binary search.
子数组最小乘积的最大值
The problem asks to find the maximum min-product of any non-empty subarray of nums.
旋转盒子
Rotate a box represented by a character matrix, letting stones fall under gravity using precise two-pointer scanning and…
向下取整数对和
The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…
找出所有子集的异或总和再求和
Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.
找出和为指定值的下标对
Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.
准时到达的列车最小时速
This problem asks to find the minimum speed of trains to reach on time using binary search.
石子游戏 VIII
Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …
数组中最大数对和的最小值
Minimize the maximum pair sum in an array by optimally pairing its elements.
矩阵中最大的三个菱形和
Find the three largest distinct rhombus sums from a given grid using array and math techniques.
两个数组最小的异或值之和
Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.
使用服务器处理任务
Assign tasks to servers efficiently using arrays and heaps, resolving ties by weight and index while tracking availabili…
准时抵达会议现场的最小跳过休息次数
Solve the problem of minimizing skips while traveling to arrive on time, using dynamic programming and state transitions…
判断矩阵经轮转后是否一致
Determine if a binary matrix can be transformed into another by rotating it 90 degrees multiple times.
使数组元素相等的减少操作次数
Find the minimum number of operations to make all array elements equal by reducing the largest elements to the next smal…
装包裹的最小浪费空间
Minimize the wasted space when packaging items into boxes, considering package and box size constraints.
检查是否区域内所有整数都被覆盖
Check if all integers in the range [left, right] are covered by intervals in a given set of ranges.
找到需要补充粉笔的学生编号
Identify the first student who will run out of chalk using a simulation with prefix sums and binary search.
最大的幻方
Find the side length of the largest magic square in a matrix where row, column, and diagonal sums are equal.
可移除字符的最大数目
Use binary search and a subsequence check to find the largest removable prefix that still keeps p inside s.
合并若干三元组以形成目标三元组
Determine if target triplet can be formed by merging given triplets using greedy selection and invariant checks.
寻找峰值 II
Locate any peak in a 2D matrix using binary search across rows or columns for efficient discovery and verification.
统计子岛屿
Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…
查询差绝对值的最小值
Compute minimum absolute differences for subarrays efficiently using array scanning and hash table lookups, leveraging b…
删除一个元素使数组严格递增
Determine if removing a single element from an array can make it strictly increasing, using a careful index check approa…
最大交替子序列和
Maximize alternating subsequence sum with dynamic programming and state transitions in an array.
设计电影租借系统
Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.
两个数对之间的最大乘积差
Find the maximum product difference between two pairs in an integer array using sorting for optimal selection.
循环轮转矩阵
This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …
基于排列构建数组
The problem asks to build an array from a given permutation using an efficient approach.
消灭怪物的最大数量
Eliminate monsters by strategically using a weapon in a video game to stop them before they reach your city.
最长公共子路径
The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…
迷宫中离入口最近的出口
Find the shortest path from the maze entrance to the nearest border exit using BFS over a 2D array matrix efficiently.
规定时间内到达终点的最小花费
Minimize the travel cost in a graph while adhering to a time constraint using state transition dynamic programming.
数组串联
This problem asks you to create an array of double the size, where each element is repeated twice in sequence.
新增的最少台阶数
Determine the fewest rungs to add to climb a strictly increasing ladder using a greedy step-by-step approach.
扣分后的最大得分
Maximize your points in a matrix by selecting cells row by row while accounting for distance penalties using dynamic pro…
查询最大基因差
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
最小未被占据椅子的编号
Solve The Number of the Smallest Unoccupied Chair by sorting arrivals and managing freed seats before each new assignmen…
描述绘画结果
Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.
队列中可以看到的人数
Compute how many people each person in a queue can see to their right using efficient stack-based state management.
子字符串突变后可能得到的最大整数
Find the largest integer by mutating a substring of a number using a mapping array for each digit.
最大兼容性评分和
Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…
删除系统中的重复文件夹
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
你可以工作的最大周数
Maximize the number of weeks you can work on projects with milestone constraints using a greedy approach and invariant v…
统计特殊子序列的数目
Learn to count all valid special subsequences in an array using state transition dynamic programming efficiently and cor…
检查操作是否合法
Determine if a move on an 8x8 board is legal by validating lines in all directions using array and matrix patterns.
K 次调整数组大小浪费的最小总空间
Find the minimum total space wasted in a dynamic array with at most k resizing operations.
检查字符串是否为数组前缀
Determine if a string is a prefix of an array by concatenating initial elements, using two-pointer scanning efficiently.
移除石子使总数最小
Minimize the total stones by repeatedly removing half from the largest pile using a greedy heap strategy.
找出到每个位置为止最长的有效障碍赛跑路线
Compute the longest valid obstacle course at each position using binary search and careful array tracking techniques eff…
作为子字符串出现在单词中的字符串数目
Count how many strings in an array appear as substrings within a given word by checking each pattern individually.
构造元素不等于两相邻元素平均值的数组
Rearrange an array such that no element equals the average of its neighbors using a greedy approach.
你能穿过矩阵的最后一天
Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.
最大方阵和
Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.
找出数组的最大公约数
Find the greatest common divisor of the smallest and largest numbers in an integer array.
找出不同的二进制字符串
Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.
最小化目标值与所选元素的差
This problem asks to select one element per row to minimize the absolute difference from a target sum using dynamic prog…
从子集的和还原数组
Reconstruct an array from given subset sums using divide and conquer approach and leveraging array properties.
学生分数的最小差值
Minimize the difference between the highest and lowest of k student scores using a sliding window approach.
找出数组中的第 K 大整数
This problem asks to find the kth largest integer in an array of string numbers, highlighting sorting and string-based c…
完成任务的最少工作时间段
Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.
找到数组的中间位置
Find the smallest middle index where the sum of elements on the left equals the sum on the right using prefix sums effic…
找到所有的农场组
Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.
树上的操作
Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.
好子集的数目
Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.
统计特殊四元组
Count Special Quadruplets requires scanning arrays and using hash lookups to efficiently find quadruplets matching sum c…
游戏中弱角色的数量
Identify all weak characters in a game by analyzing attack and defense values using a stack-based greedy sorting approac…
访问完所有房间的第一天
Calculate the first day you have visited all rooms using state transition dynamic programming on the nextVisit array.
数组的最大公因数排序
The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.
可互换矩形的组数
Count all pairs of rectangles that share the exact width-to-height ratio using efficient array scanning and hash lookup.
差的绝对值为 K 的数对数目
Find how many pairs (i, j) with i < j satisfy |nums[i] - nums[j]| == k using array scanning and hash lookup.
从双倍数组中还原原数组
Given a shuffled array, determine if it is a doubled array and find the original array.
出租车的最大盈利
Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.
使数组连续的最少操作数
Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…
执行操作后的变量值
Compute the final value of X by simulating each string operation in the array sequentially with careful tracking.
数组美丽值求和
Calculate the sum of beauty for array elements using prefix and suffix tracking to optimize evaluation across indices ef…
检测正方形
Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…
增量元素之间的最大差值
Find the maximum difference between two increasing elements in an array using a linear scan to track the minimum value e…
网格游戏
Solve the Grid Game problem by optimizing the movement of two robots on a 2D matrix grid.
判断单词是否能放入填字游戏内
Determine if a word fits in a crossword grid using array and matrix checks, accounting for spaces, letters, and blocked …
解出数学表达式的学生分数
Calculate student scores for a single-digit math expression using state transition dynamic programming to track all vali…
将一维数组转变成二维数组
Convert a 1D integer array into a structured 2D array with specified rows and columns using all elements sequentially.
连接后等于目标字符串的字符串对
Count all unique index pairs in a string array whose concatenation exactly matches the given target string using efficie…
分割数组的最多方案数
Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…
找出缺失的观测数据
Given a set of dice rolls, calculate the missing observations based on the mean and return them or determine if it's imp…
石子游戏 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…
至少在两个数组中出现的值
Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…
获取单值网格的最小操作数
Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.
将数组分成两个数组并最小化数组和的差
Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…
使每位学生都有座位的最少移动次数
Calculate the minimum total moves to seat each student using greedy assignment and invariant validation efficiently.
网络空闲的时刻
Calculate the time when the network becomes idle, factoring in message resending and the BFS traversal method.
两个有序数组的第 K 小乘积
Find the kth smallest product from two sorted arrays using binary search across possible product values efficiently.
简易银行系统
Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…
统计按位或能得到最大值的子集数目
Determine the number of non-empty subsets that achieve the maximum bitwise OR using efficient backtracking and pruning s…
统计最高分的节点数目
Find the number of nodes with the highest score in a binary tree, based on subtree sizes and node removal.
并行课程 III
Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…
数组中第 K 个独一无二的字符串
Find the kth distinct string in an array by identifying strings that appear only once, using efficient array scanning an…
两个最好的不重叠活动
Maximize the total value of at most two non-overlapping events using state transition dynamic programming efficiently.
蜡烛之间的盘子
Determine the number of plates between candles in a given substring using binary search and prefix sum techniques.
棋盘上有效移动组合的数目
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
值相等的最小索引
Find the smallest index where the index mod 10 equals the value at that index in the given array.
转化数字的最小运算数
Determine the minimum operations needed to convert a number using array elements with addition, subtraction, or XOR oper…
分配给商店的最多商品的最小值
Distribute products to stores so the largest store allocation is minimized using binary search over possible maximums.
最大化一张图中的路径价值
Calculate the maximum path quality in a graph using backtracking and pruning to optimize node visits within time limits …
每一个查询的最大美丽值
Determine the maximum beauty of items affordable for each query using efficient binary search and sorting techniques.
你可以安排的最多任务数目
Maximize the number of tasks that can be completed by efficiently using workers and magical pills.
买票需要的时间
Calculate the total time for a specific person to buy all their tickets using queue-driven state processing.
两栋颜色不同且距离最远的房子
Maximize the distance between two houses with different colors by using a greedy approach and validating the choice.
给植物浇水
Simulate watering plants while managing a watering can's capacity, considering distance and refills.
区间内查询数字的频率
Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…
统计出现过一次的公共字符串
Learn how to efficiently count strings appearing exactly once in both arrays using array scanning and hash lookup patter…
网格图中机器人回家的最小代价
Find the minimum cost for a robot to return home in a grid with row and column movement costs.
统计农场中肥沃金字塔的数目
Solve Count Fertile Pyramids in a Land with matrix DP that measures the tallest pyramid rooted at each fertile cell.
找出数组排序后的目标下标
Find the target indices of a sorted array and return them in increasing order using binary search and sorting techniques…
半径为 k 的子数组平均值
Efficiently calculate the k-radius average for subarrays using sliding window technique.
从数组中移除最大值和最小值
The problem asks to remove the minimum and maximum elements from an array with the fewest deletions.
找出 3 位偶数
Generate unique 3-digit even numbers from a given array of digits with duplicates.
找到和最大的长度为 K 的子序列
Pick the k largest values, then restore their original order to build the maximum-sum subsequence correctly.
适合野炊的日子
Find good days to rob the bank by identifying days with non-increasing and non-decreasing guard counts using dynamic pro…
引爆最多的炸弹
Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …
子数组范围和
Compute the total sum of ranges for all contiguous subarrays efficiently using stack-based state management techniques.
给植物浇水 II
Simulate watering a row of plants with Alice and Bob using two-pointer scanning, tracking refills precisely for each ste…
摘水果
Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.
找出数组中的第一个回文字符串
Return the first palindromic string from an array of words or an empty string if none exists.
向字符串添加空格
Learn to efficiently insert spaces in a string using two-pointer scanning with invariant tracking in linear time.
股票平滑下跌阶段的数目
Count all contiguous periods where stock prices descend smoothly by exactly one using dynamic programming techniques.
使数组 K 递增的最少操作次数
This problem requires finding the minimum number of operations to make an array K-increasing using binary search over th…
句子中的最多单词数
Find the maximum number of words in a single sentence from an array of sentences using array and string processing techn…
从给定原材料中找到所有可以做出的菜
Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …
相同元素的间隔之和
Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.
还原原数组
Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…
银行中的激光束数量
Calculate total laser beams in a bank floor plan using array counting and math logic between security devices on differe…
摧毁小行星
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…
检查是否每一行每一列都包含全部整数
Determine if every row and column in a square matrix contains all numbers from 1 to n without repetition using array sca…
最少交换次数来组合所有的 1 II
Solve the minimum swaps to group all 1's together in a circular binary array using an optimized sliding window approach.
统计追加字母可以获得的单词数
Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …
全部开花的最早一天
Find the earliest day where all flower seeds are blooming based on their planting and growth times, using a greedy strat…
解决智力问题
Maximize points in an exam with state transition dynamic programming by deciding whether to solve or skip each question.
同时运行 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.
统计隐藏数组数目
Given a sequence of differences, count how many hidden sequences fit within a range using an array and prefix sum approa…
价格范围内最高排名的 K 样物品
Use BFS to rank reachable shop items by distance, price, row, and column, then return the best k coordinates.
元素计数
Count elements in an array that have both strictly smaller and strictly greater numbers using array sorting efficiently.
按符号重排数组
Rearrange an array by alternating positive and negative integers using a two-pointer approach with invariant tracking.
找出数组中的所有孤独数字
Find lonely numbers in an array where each lonely number appears once and has no adjacent values.
基于陈述统计最多好人数
Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.
将找到的值乘以 2
The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …
分组得分最高的所有下标
Find all indices in a binary array where division score is maximized.
根据给定数字划分数组
Rearrange an array around a pivot while maintaining relative order using a two-pointer scanning approach efficiently.
删除元素后和的最小差值
Minimize the difference between sums after removing n elements from a 3n array by dividing the remaining elements into t…
对奇偶下标分别排序
Rearrange a 0-indexed array by sorting even and odd indices independently for predictable order and correctness.
设计位集
Master the Design Bitset problem by efficiently managing bit flips, counts, and indexed updates with array and hash look…
使数组变成交替数组的最少操作数
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.
数组的最大与和
Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.
统计数组中相等且可以被整除的数对
Given an array, count pairs of elements that are equal and their indices product is divisible by a given integer.
统计数组中好三元组数目
Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.
统计可以被 K 整除的下标对数目
Count Array Pairs Divisible by K requires counting index pairs whose products are divisible by a given number k.
统计包含给定前缀的字符串
Count how many words in a list start with a given prefix.
完成旅途的最少时间
Find the minimum time required for buses to complete at least totalTrips using binary search over time multiples.
完成比赛的最少时间
Minimize the time to complete a race with tire swaps using dynamic programming and state transitions.
数组中紧跟 key 之后出现最频繁的数字
Scan the array once, count which value appears right after the key, and return the uniquely most frequent follower.
将杂乱无章的数字排序
Sort numbers based on a custom mapping of their digits, leveraging array manipulation and sorting techniques.
向数组中追加 K 个整数
In this problem, you need to append k unique positive integers to a given array nums such that the sum is minimized.
根据描述创建二叉树
Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.
替换数组中的非互质数
Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…
找出数组中的所有 K 近邻下标
Identify all indices in an array that are within k distance of elements equal to the given key using two-pointer scannin…
统计可以提取的工件
Count the number of artifacts that can be extracted after excavating specified grid cells.
K 次操作后最大化顶端元素
Maximize the topmost element in a pile after making exactly k moves using a greedy strategy and invariant checks.
将数组划分成相等数对
Determine if an array of 2n integers can be partitioned into n pairs where each pair contains identical elements using h…
将数组和减半的最少操作次数
Minimize operations to halve an array's sum using greedy choices and heap data structures.
统计数组中峰和谷的数量
Count Hills and Valleys in an Array determines the number of hills and valleys in a given array by analyzing index neigh…
射箭比赛中的最大得分
In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…
由单个字符重复的最长子字符串
Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…
找出两数组的不同
Find the Difference of Two Arrays helps you identify unique elements between two integer arrays using array scanning and…
美化数组的最少删除数
Determine the minimum deletions required to transform an array into a beautiful sequence using stack-based state managem…
找到指定长度的回文数
Find the smallest palindromes of a given length for specific queries with mathematical and array manipulation.
从栈中取出 K 个硬币的最大面值和
Optimize coin selection across multiple piles using state transition dynamic programming to achieve the maximum wallet v…
数组的三角和
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
找出输掉零场或一场比赛的玩家
Identify players with zero or one losses by efficiently scanning arrays and counting losses using hash lookups for accur…
每个小孩最多能分到多少糖果
Maximize candies allocation for k children by dividing piles into sub-piles using binary search.
加密解密字符串
The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …
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…
找到最接近 0 的数字
Identify the number in an integer array that is closest to zero, returning the larger one if tied.
设计一个 ATM 机器
Design an ATM machine that stores and withdraws money with given denominations and prioritizes larger values during with…
节点序列的最大得分
Find the maximum score of a valid node sequence in an undirected graph with given node scores and edges.
完成所有任务需要的最少轮数
The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.
转角路径的乘积中最多能有几个尾随零
Find the maximum trailing zeros in the product of a cornered path within a 2D grid.
相邻字符不同的最长路径
Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…
多个数组求交集
Find integers that are common across all arrays in a given list of arrays.
统计圆内格点数目
Count the number of lattice points inside at least one circle in a grid, based on given center and radius data.
统计包含每个点的矩形数目
Given a set of rectangles and points, determine how many rectangles contain each point.
花期内花的数目
Find the number of flowers in full bloom at the given times for a list of people.
统计是给定字符串前缀的字符串数目
Count Prefixes of a Given String is a problem that involves finding the number of string prefixes in an array that match…
最小平均差
Find the index with the minimum average difference in an array using prefix sums.
统计网格图中没有被保卫的格子数
Solve Count Unguarded Cells in the Grid by marking guard sight lines across a blocked matrix and counting untouched empt…
逃离火灾
Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…
必须拿起的最小连续卡牌数
Solve Minimum Consecutive Cards to Pick Up by tracking each card's last index and minimizing duplicate spans during one …
含最多 K 个可整除元素的子数组
Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…
检查是否有合法括号字符串路径
Check if there exists a valid parentheses string path in a given grid using state transition dynamic programming.
分割数组的方案数
Count all valid ways to split a 0-indexed integer array into two non-empty parts using array plus prefix sum logic effic…
毯子覆盖的最多白色砖块数
Solve Maximum White Tiles Covered by a Carpet by sorting intervals, checking optimal carpet starts, and counting full pl…
最大波动的子字符串
Find the largest variance possible in any substring of a given string using dynamic programming.
移除字母异位词后的结果数组
This problem requires removing adjacent anagrams from a list of words using an array scanning and hash lookup approach.
不含特殊楼层的最大连续楼层数
Find the maximum sequence of consecutive floors without any special floors using array sorting techniques efficiently.
按位与结果大于零的最长组合
Find the largest group of integers in an array whose bitwise AND is greater than zero using array scanning and hash look…
装满石头的背包的最大数量
Maximize the number of bags filled to capacity by distributing additional rocks using a greedy approach.
表示一个折线图的最少线段数
Determine the fewest lines needed to accurately connect stock price points in a line chart using array and math reasonin…
巫师的总力量和
The Sum of Total Strength of Wizards problem asks for the sum of the total strengths of all contiguous subarrays of wiza…
最多单词数的发件人
Find the sender with the largest total word count by scanning messages and tallying counts using a hash table efficientl…
使数组按非递减顺序排列
Determine the minimum steps to make an array non-decreasing using linked-list pointer manipulation and monotonic stack t…
到达角落需要移除障碍物的最小数目
Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.
极大极小游戏
The Min Max Game problem requires simulating an array reduction process to find the last remaining number.
划分数组使最大差为 K
Find the minimum number of subsequences required such that the difference between the maximum and minimum value in each …
替换数组中的元素
Replace Elements in an Array involves applying a series of operations to replace values in an array with new ones based …
咒语和药水的成功对数
Count how many potions pair successfully with each spell using binary search over sorted potion strengths efficiently.
替换字符后匹配
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
统计得分小于 K 的子数组数目
Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…
计算应缴税款总额
Calculate the total tax owed by iterating through sorted brackets and applying each rate incrementally to your income.
网格中的最小路径代价
Minimize the cost of a path in a grid while considering move costs for each step.
公平分发饼干
The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…
公司命名
The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…
卖木头块
Maximize your profit by cutting a wooden piece into smaller parts based on given prices and dimensions.
操作后的最大异或和
Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.
判断矩阵是否是一个 X 矩阵
Check if a square matrix follows the X-Matrix pattern by validating diagonal and non-diagonal conditions.
拼接数组的最大分数
Maximize the score of two arrays by splicing and swapping a subarray using dynamic programming.
从树中删除边的最小分数
Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.
螺旋矩阵 IV
In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.
网格图中递增路径的数目
Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…
坐上公交的最晚时间
Find the latest time to catch a bus based on departure times, passenger arrivals, and capacity using binary search over …
最小差值平方和
Calculate the minimum sum of squared differences between two arrays using limited modifications and binary search techni…
元素值大于变化阈值的子数组
Find the size of a subarray with all elements greater than threshold divided by length using stack-based state managemen…
装满杯子需要的最短总时长
Determine the minimum seconds to fill cups of cold, warm, and hot water using a greedy selection strategy and invariant …
数组能形成多少数对
Given an array, count how many pairs can be formed and how many leftovers remain after pairing.
数位和相等数对的最大和
Find the maximum sum of two numbers with equal digit sums in a given array of positive integers.
裁剪数字后查询第 K 小的数字
Solve the Query Kth Smallest Trimmed Number problem by efficiently trimming and sorting strings in an array to answer qu…
使数组可以被整除的最少删除次数
Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.
最好的扑克手牌
Determine the strongest poker hand from five cards using array scanning and hash table counting techniques efficiently.
全 0 子数组的数目
Given an array of integers, count the subarrays that consist entirely of 0s.
不可能得到的最短骰子序列
Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…
相等行列对
Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…
设计食物评分系统
Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.
优质数对的数目
Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…
使数组中所有元素都等于零
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…
合并相似的物品
Merge Similar Items combines values and weights from two lists, returning the result sorted by value.
统计坏数对的数目
Count the number of bad pairs in an array where the difference between indices and values does not match.
任务调度器 II
Complete tasks in the optimal number of days by considering breaks and task type constraints.
将数组排序的最少替换次数
Minimize the number of operations to make the array sorted in non-decreasing order by replacing elements with sums of tw…
等差三元组的数目
Count the number of arithmetic triplets in a given strictly increasing array with a specified difference.
受限条件下可到达节点的数目
In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…
检查数组是否存在有效划分
This problem challenges you to determine if an array can be partitioned into valid subarrays using dynamic programming.
矩阵中的局部最大值
Find the largest value in every 3x3 submatrix of an n x n integer matrix efficiently using nested loops.
字母移位 II
Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.
删除操作后的最大子段和
Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…
赢得比赛需要的最少训练时长
Find the minimum hours of training needed to beat all opponents in a competition based on energy and experience.
找出数组的第 K 大和
Find the K-Sum of an Array requires computing the kth largest subsequence sum in an array using sorting and heap techniq…
和有限的最长子序列
Find the maximum size of a subsequence from nums with a sum less than or equal to each query value.
收集垃圾的最少总时间
This problem asks you to find the minimum amount of time needed to collect all garbage in a city, focusing on array and …
给定条件下构造矩阵
Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…
和相等的子数组
Find Subarrays With Equal Sum is solved by scanning adjacent pairs and storing each length-2 sum in a hash set.
被列覆盖的最多行数
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
预算内的最多机器人数目
Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…
检查相同字母间的距离
Verify if each pair of identical letters in a string has the exact number of letters between them as specified in a dist…
最长优雅子数组
Find the length of the longest nice subarray where the bitwise AND of all pairs of elements in the subarray is zero.
会议室 III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
出现最频繁的偶数元素
Identify the most frequent even element in an array using counting and hash lookup, handling ties by choosing the smalle…
将区间分为最少组数
Determine the minimum number of non-overlapping groups for a set of intervals using precise two-pointer scanning logic.
最长递增子序列 II
Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…
运动员和训练师的最大匹配数
Maximize the number of valid player-trainer matchings using two-pointer scanning and careful sorting strategy.
按位或最大的最小子数组长度
Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.
完成所有交易的初始最少钱数
Find the minimum money required to complete all transactions in any order while considering cost and cashback.
字符串的前缀分数和
The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …
按身高排序
Sort the People requires pairing names with heights and sorting them in descending height order efficiently using arrays…
按位与最大的最长子数组
Find the length of the longest subarray whose bitwise AND reaches the array's maximum value, combining array scanning wi…
找到所有好下标
Identify all indices in an array where the k-length prefix is non-increasing and the k-length suffix is non-decreasing.
好路径的数目
Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.
所有数对的异或和
Compute the overall bitwise XOR from all pairings between two arrays using efficient array and bit manipulation techniqu…
满足不等式的数对数目
Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.
沙漏的最大总和
Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…
处理用时最长的那个任务的员工
Identify which employee spent the longest time on a task using an array-driven approach, analyzing each log entry effici…
找出前缀异或的原始数组
Find the original array from a given prefix XOR array using bitwise manipulation techniques.
矩阵中和能被 K 整除的路径
Compute all paths in a matrix where the sum of elements is divisible by k using state transition dynamic programming eff…
二的幂数组中查询范围内的乘积
The Range Product Queries of Powers problem requires calculating the product of powers of 2 for a range of queries on a …
最小化数组中的最大值
Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …
创建价值相同的连通块
Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.
与对应负数同时存在的最大正整数
Find the largest positive integer in an array such that its negative counterpart also exists.
反转之后不同整数的数目
This problem requires counting distinct integers after performing reverse operations on each integer in an array.
统计定界子数组的数目
Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.
判断两个事件是否存在冲突
Compare two same-day time intervals and check whether their inclusive endpoints overlap after converting HH:MM strings i…
最大公因数等于 K 的子数组数目
Count the number of subarrays with GCD equal to a given value k from a list of integers.
使数组相等的最小开销
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 …
差值数组不同的字符串
Identify the one string in an array whose consecutive letter differences deviate from all others using array scanning pl…
距离字典两次编辑以内的单词
Identify all words in queries that can match dictionary entries with at most two character changes efficiently using arr…
摧毁一系列目标
Find the minimum seed value to destroy the most targets on a number line, using array scanning and hash lookup.
下一个更大元素 IV
Find the second greater integer for each element in an array using binary search and monotonic stack techniques.
可被三整除的偶数的平均值
Find the average of even numbers divisible by 3 from an array of positive integers.
最流行的视频创作者
Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…
移除子树后的二叉树高度
Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…
对数组执行操作
Transform an array by applying adjacent doubling operations and shifting zeros efficiently using two-pointer scanning te…
长度为 K 子数组中的最大和
Find the maximum sum of all distinct-element subarrays of length k using array scanning and hash lookup techniques.
雇佣 K 位工人的总代价
Optimize the total cost of hiring exactly k workers using a two-pointer approach with invariant tracking and priority qu…
最小移动总距离
Optimize the total distance traveled by robots to factories using dynamic programming, sorting, and state transitions.
不同的平均值数目
Calculate the number of unique averages formed by repeatedly pairing smallest and largest elements efficiently using has…
树上最大得分和路径
Solve the 'Most Profitable Path in a Tree' problem using graph traversal and depth-first search techniques to maximize A…
最小公倍数等于 K 的子数组数目
Find the number of subarrays in an array where the least common multiple (LCM) of the subarray equals a given integer k.
数组中不等三元组的数目
Count all triplets in a positive integer array where each element is distinct using scanning and hash lookup efficiently…
二叉搜索树最近节点查询
Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…
行和列中一和零的差值
This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…
统计中位数为 K 的子数组
Count the number of subarrays in a given array with median equal to a specified value k.
划分技能点相等的团队
Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.
数组中字符串的最大值
The problem requires finding the maximum value of alphanumeric strings in an array based on length or numeric value.
图中最大星和
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.
删除每行中的最大值
Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…
数组中最长的方波
Find the length of the longest subsequence where each element is a perfect square of its previous one.
设计内存分配器
Design a memory allocator that simulates allocation and deallocation of memory blocks.
矩阵查询可获得的最大分数
Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.
统计相似字符串对的数目
Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…
查询树中环的长度
Solve the problem of determining cycle lengths in a binary tree with added edges through queries.
最多可以摧毁的敌人城堡数目
Find the maximum number of enemy forts that can be captured by moving your army using two-pointer scanning with invarian…
奖励最顶尖的 K 名学生
Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…
到目标字符串的最短距离
Find the shortest distance to a target string in a circular array with either left or right movement options.
礼盒的最大甜蜜度
Maximize the tastiness of a candy basket by choosing k candies from a list of candy prices.
好分区的数目
Calculate the number of great partitions of an array using state transition dynamic programming with careful sum constra…
数组乘积中的不同质因数数目
Find the number of distinct prime factors in the product of an array of integers.
查询数组异或美丽值
Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.
最大化城市的最小电量
Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…
正整数和负整数的最大计数
Compute the maximum count between positive and negative integers in a sorted array using efficient binary search countin…
执行 K 次操作后的最大分数
Maximize your score by applying exactly k operations on an array using greedy selection and heap optimization techniques…
过桥的时间
Time to Cross a Bridge involves simulating worker movements using arrays and heaps to determine when the last worker cro…
数组元素和与数字和的绝对差
Find the absolute difference between element sum and digit sum of an array of integers.
子矩阵元素加 1
Increment Submatrices by One focuses on efficiently updating submatrices using row-wise prefix sums in an n by n matrix.
统计好子数组的数目
Count the number of subarrays that contain at least k pairs of equal elements using array scanning and hash lookup.
最大价值和与最小价值和的差值
Compute the maximum difference between any path price sum in a tree using binary-tree traversal and state tracking effic…
最小公共值
Find the smallest integer appearing in both sorted arrays efficiently using array scanning and hash-based lookup techniq…
使数组中所有元素相等的最小操作数 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.
根据第 K 场考试的分数排序
Sort a matrix of student scores by the kth exam efficiently using array manipulation and custom sorting techniques.
拆分数组的最小代价
Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…
统计桌面上的不同数字
Compute the number of distinct integers generated on a board using repeated modulo operations over a long sequence of da…
将珠子放入背包中
The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…
统计上升四元组
Given a permutation of numbers, count the number of increasing quadruplets using dynamic programming.
分割数组中数字的数位
Given an array of positive integers, separate each integer into its individual digits while preserving the original orde…
从一个范围内选择最多整数 I
Determine the maximum count of integers from 1 to n avoiding banned numbers while keeping the sum under maxSum.
两个线段获得的最多奖品
Maximize the total prizes by choosing two segments of length k on a sorted line of prize positions efficiently using bin…
二进制矩阵中翻转最多一次使路径不连通
Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…
从数量最多的堆取走礼物
Take Gifts From the Richest Pile uses a heap to simulate the process of taking gifts from the richest pile over a number…
统计范围内的元音字符串数
Count the number of strings that start and end with a vowel in given ranges within an array of words.
打家劫舍 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…
找出数组的串联值
Compute the array concatenation value efficiently using two-pointer scanning while maintaining a running total of concat…
统计公平数对的数目
Efficiently count all fair pairs in an array using sorting and binary search, focusing on the sum range between lower an…
子字符串异或查询
Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…
修改两个元素的最小分数
The problem asks for the minimum score after changing two elements of an array using a greedy approach.
最小无法得到的或值
Find the smallest positive integer that cannot be formed from any subsequence OR combination in the array.
更新数组后处理求和查询
Solve the Handling Sum Queries After Update problem using arrays and segment trees with lazy propagation for efficiency.
合并两个二维数组 - 求和法
Merge two 2D arrays by summing values with matching ids using array scanning and hash lookup efficiently.
无平方子集计数
Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…
找出对应 LCP 矩阵的字符串
Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.
左右元素和的差值
Compute absolute differences between left and right cumulative sums for each element in an integer array efficiently.
找出字符串的可整除数组
Calculate the divisibility array for a string by checking if prefixes are divisible by a given number.
求出最多标记下标
Maximize marked indices in an array by performing allowed operations, applying binary search to find the optimal count e…
在网格图中访问一个格子的最少时间
Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…
统计将重叠区间合并成组的方案数
Count Ways to Group Overlapping Ranges is a medium difficulty problem focused on array manipulation and sorting to count…
统计可能的树根数目
Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.
分割数组使乘积互质
Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…
获得分数的方法数
Find the number of ways to earn exactly target points using multiple types of exam questions with distinct marks.
统计范围内的元音字符串数
Count the Number of Vowel Strings in Range asks to count vowel strings in a subarray of a given word list.
重排数组以得到最大前缀分数
Maximize the number of positive prefix sums by rearranging an integer array using a greedy, order-focused strategy.
统计美丽子数组数目
Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…
完成所有任务的最少时间
Determine the minimum active time for a computer to complete all scheduled tasks within their specific time windows effi…
最大化数组的伟大值
Maximize Greatness of an Array requires permuting numbers to exceed original values at most indices efficiently.
标记所有元素后数组的分数
The problem involves marking elements in an array and calculating the score based on adjacent elements.
修车的最少时间
Find the minimum time to repair all cars using mechanics with different ranks, applying binary search over possible time…
检查骑士巡视方案
Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.
美丽子集的数目
Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…
执行操作后的最大 MEX
Find the smallest missing non-negative integer after repeated additions or subtractions of a given value in nums array e…
质数减法运算
Determine if it's possible to make the array strictly increasing using prime subtractions.
使数组元素全部相等的最少操作次数
Find the minimum number of operations to make all elements in an array equal for each query.
收集树中金币
The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…
从两个数字数组里生成最小数字
Given two arrays of digits, find the smallest possible number formed by one digit from each array.
找到最大开销的子字符串
Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…
使子数组元素和相等
Solve Make K-Subarray Sums Equal by grouping circular indices with gcd cycles and minimizing each group to its median.
转换二维数组
Learn how to convert an integer array into a 2D array with distinct rows using array scanning plus hash lookup efficient…
老鼠和奶酪
In 'Mice and Cheese', you must maximize the total reward of two mice eating cheese while respecting their preferences an…
最少翻转操作数
Find the minimum number of operations to move a 1 in an array from a given start position to other positions, considerin…
对角线上的质数
Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…
等值距离和
In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…
最小化数对的最大差值
Minimize the Maximum Difference of Pairs seeks to optimize the maximum pairwise difference in a set of index pairs from …
网格图中最少访问的格子数
Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…
查询网格图中每一列的宽度
This problem asks you to compute the width of each column in a grid, where the width is defined by the length of the lar…
一个数组所有前缀的分数
Compute the score of each prefix in an array using conversion rules while tracking the maximum efficiently for prefix su…
一最多的行
Find the row with the maximum ones in a binary matrix and return its index and count.
找出可整除性得分最大的整数
Determine the divisor with the highest count of divisible elements in an array using a clear array-driven strategy.
最小化旅行的价格总和
Calculate the minimum total cost of multiple trips on a tree by selectively halving node prices using DFS frequency coun…
滑动子数组的美丽值
Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…
使数组所有元素变成 1 的最少操作次数
Find the minimum number of operations to transform every element of a positive integer array into 1 using gcd operations…
K 个元素的最大和
Maximize your score by performing exactly k operations on an array using a greedy approach to select the highest values.
找到两个数组的前缀公共数组
This problem challenges you to find the prefix common array of two integer permutations, utilizing array scanning and ha…
网格图中鱼的最大数目
Maximize the number of fish that can be caught by performing DFS on an optimal starting point in a grid.
将数组清空
Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.
保龄球游戏的获胜者
Simulate a bowling game to determine the winner based on hit pins per turn for two players.
找出叠涂元素
Find the first index where a row or column is completely painted in a matrix based on an array of integers.
前往目标的最小代价
Find the minimum cost path between two points, using special roads or direct moves in a 2D space.
找出不同元素数目差数组
Calculate the distinct difference array of a given list of integers by counting distinct elements in the prefix and suff…
有相同颜色的相邻元素数目
Calculate the number of adjacent elements sharing the same color after sequentially updating an initially zeroed array u…
使二叉树所有路径值相等的最小代价
Minimize the cost increments required to equalize path costs in a binary tree from root to leaves.
老人的数目
Determine how many passengers are over 60 years old based on their compressed details in an array of strings.
矩阵中的和
Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…
最大或值
Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.
英雄的力量
Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…
找出转圈游戏输家
Simulate a ball-passing game around a circle using array scanning and hash lookup to find friends who never receive the …
相邻值的按位异或
Determine if a binary array original exists that produces the given derived array using neighboring bitwise XOR logic.
矩阵中移动的最大次数
Maximize the number of moves in a grid starting from the first column using state transition dynamic programming.
购买两块巧克力
Determine the leftover money after buying exactly two chocolates using a greedy selection and sum validation approach.
字符串中的额外字符
The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…
一个小组的最大实力值
Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…
最大公约数遍历
Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.
对角线上不同值的数量差
Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.
矩阵中严格递增的单元格数
Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…
半有序排列
Find the minimum number of operations to convert a permutation into a semi-ordered permutation where 1 is first and n is…
查询后矩阵的和
Calculate the total sum of a zero-filled n x n matrix after sequentially applying row and column update queries efficien…
移动机器人
Calculate total distances between robots moving on a number line while accounting for collisions using array plus braint…
找到矩阵中的好子集
Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…
既不是最小值也不是最大值
Find a number in an array that is neither the minimum nor maximum value, or return -1 if no such number exists.
收集巧克力
Calculate the minimum cost to collect all chocolate types using rotations and purchases in an array-based enumeration pa…
最大和查询
Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…
找出分区值
Find the minimum partition value by dividing a positive integer array into two subarrays using sorting for efficiency.
特别的排列
Count the number of special permutations for a given array using dynamic programming and bit manipulation.
给墙壁刷油漆
Compute the minimum cost to paint all walls using a paid and free painter with state transition dynamic programming.
最大字符串配对数目
Find the maximum number of pairs of distinct strings from an array where one string is the reverse of the other.
字符串连接删减字母
Solve the Decremental String Concatenation problem by applying dynamic programming to minimize string length after conca…
统计没有收到请求的服务器数目
Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…
美丽下标对的数目
Count all index pairs in an array where the first digit of one number and last digit of another are coprime efficiently.
将数组划分成若干好子数组的方式
Calculate the number of ways to partition a binary array into good subarrays using state transition dynamic programming …
机器人碰撞
Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.
最长奇偶子数组
Determine the length of the longest subarray where elements alternate even and odd while staying below a given threshold…
和等于目标值的质数对
Find all prime number pairs that sum up to a given integer n using an efficient sieve-based array approach.
不间断子数组
Count all continuous subarrays efficiently using sliding window with running max-min state tracking for array consistenc…
所有子数组中不平衡数字之和
Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.
最长交替子数组
Find the longest alternating subarray in a given array of integers.
重新放置石块
Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.
黑格子的数目
Calculate the number of black blocks in a grid given a list of black cell coordinates.
达到末尾下标所需的最大跳跃次数
Find the maximum number of jumps to reach the last index using state transition dynamic programming efficiently in array…
构造最长非递减子数组
Maximize the length of a non-decreasing subarray by optimally choosing elements from two arrays using dynamic programmin…
使数组中的所有元素都等于零
Determine if all elements in a given array can be reduced to zero using repeated k-length prefix operations efficiently.
特殊元素平方和
Calculate the sum of squares of special elements in a 1-indexed array using index divisibility checks efficiently.
数组的最大美丽值
Find the maximum beauty of an array by adjusting elements within a range using binary search and sliding window techniqu…
合法分割的最小下标
Find the minimum index to split an array such that both subarrays have the same dominant element.
最长合法子字符串的长度
This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.
检查数组是否是好的
Determine if a given integer array is a permutation of base[n], containing 1 to n-1 once and n twice, using scanning and…
访问数组中的位置使分数最大
Maximize your score by visiting positions in an array while handling penalties for parity changes efficiently with DP.
按分隔符拆分字符串
Split Strings by Separator requires iterating through an array of strings and splitting each by a given separator charac…
合并后数组中的最大元素
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…
满足目标工作时长的员工数目
Determine how many employees reach the required work hours using a direct array-driven counting approach.
统计完全子数组的数目
Count Complete Subarrays in an Array requires scanning the array while tracking elements to detect subarrays with all di…
使循环数组所有元素相等的最少秒数
Find the minimum number of seconds to equalize a circular array using array scanning and hash lookup techniques.
使数组和小于等于 x 的最少时间
Calculate the minimum seconds to reduce the array sum to at most x using optimal single-time reductions per index effici…
判断是否能拆分数组
Determine whether an array can be fully split into single-element subarrays using a state transition dynamic programming…
找出最安全路径
Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.
子序列最大优雅度
Maximize elegance of a k-length subsequence from a list of items with profits and categories.
数组中的最大数对和
Find the maximum sum of two numbers in an array sharing the same largest digit using a hash-based scan efficiently.
限制条件下元素之间的最小绝对差
Find the minimum absolute difference between two array elements that are at least x indices apart using binary search.
操作使得分最大
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
统计和小于目标的下标对数目
This problem asks you to count all index pairs in an array whose sum is strictly less than a given target value efficien…
将三个组排序
Determine the minimum removals to make an array of 1s, 2s, and 3s non-decreasing using dynamic programming transitions.
判别首字母缩略词
Check if a string can be formed by concatenating the first letters of each word in a given list.
销售利润最大化
Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…
找出最长等值子数组
Find the maximum length of an equal subarray after removing up to k elements using array scanning and hash-based index t…
使子序列的和等于目标的最少操作次数
The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …
在传球游戏中最大化函数值
Maximize the total score in a ball-passing game by selecting the best starting player using state transition dynamic pro…
几乎唯一子数组的最大和
Find the maximum sum of subarrays that contain at least m distinct elements using array scanning and hash lookups effici…
统计趣味子数组的数目
Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …
边权重均等查询
Find the minimum number of operations to equalize edge weights in a tree between given pairs of nodes.
与车相交的点
Count covered integer points by merging overlapping car intervals or marking visited positions on the number line.
将石头分散到网格图的最少移动次数
Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…
使数组成为递增数组的最少右移次数
Determine the minimum number of right shifts to sort a distinct integer array or return -1 if impossible using array ana…
删除数对后的最小数组长度
This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.
统计距离为 k 的点对
Solve the problem of counting pairs of points with distance k using array scanning and hash table techniques.
计算 K 置位下标对应元素的和
Sum values in an array where the indices have exactly k set bits in binary representation.
让所有学生保持开心的分组方法数
The Happy Students problem asks how many ways a teacher can select a group of students so everyone is happy, based on ce…
最大合金数
Determine the maximum number of alloys possible using limited metal stock and budget, leveraging binary search efficient…
完全子集的最大元素和
Given a 1-indexed array, select a subset where indices' product is a perfect square, then return the maximum sum.
美丽塔 I
Solve Beautiful Towers I by testing each peak and enforcing mountain limits with monotonic stack style height propagatio…
美丽塔 II
Maximize tower configurations with the stack-based approach while ensuring mountain-like patterns in this medium difficu…
收集元素的最少操作次数
Scan from the end, track seen values from 1 to k, and stop once every required number is collected.
使数组为空的最少操作次数
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…
有序三元组中的最大值 I
Find the maximum value of a triplet in an array where indices follow the order i < j < k.
有序三元组中的最大值 II
Solve Maximum Value of an Ordered Triplet II in linear time by tracking the best left difference and right multiplier.
无限数组的最短子数组
Find the shortest subarray in an infinite array that sums to a given target using array scanning and hash lookup.
最小处理时间
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.
上一个遍历的整数
This problem involves finding the last visited integer for each -1 in a given array by simulating a stack-like behavior.
最长相邻不相等子序列 I
Find the longest alternating subsequence in a string array based on a binary group array.
最长相邻不相等子序列 II
Find the longest subsequence of indices such that the corresponding strings have a valid Hamming distance and group cons…
和带限制的子多重集合的数目
This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.
找出满足差值条件的下标 I
Find two indices in an array where their difference in both index and value meets specified thresholds.
找出满足差值条件的下标 II
Locate two indices in an array where both index and value differences meet specified thresholds using precise scanning t…
构造乘积矩阵
Solve the "Construct Product Matrix" problem by calculating the product of elements in 2D matrices without division.
元素和最小的山形三元组 I
Find the minimum sum of a mountain triplet in an array of integers, or return -1 if no valid triplet exists.
元素和最小的山形三元组 II
Find the minimum sum of a valid mountain triplet in an integer array, or return -1 if no valid triplet exists.
合法分组的最少组数
The problem involves sorting balls into boxes while minimizing the number of boxes, adhering to size constraints.
子数组不同元素数目的平方和 I
Compute the sum of squares of distinct elements for all subarrays using array scanning with hash lookups efficiently.
和为目标值的最长子序列的长度
Find the length of the longest subsequence in an array that sums to a target value, using dynamic programming.
子数组不同元素数目的平方和 II
Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.
找出数组中的 K-or 值
Given an integer array nums and an integer k, find the K-or of nums where bits qualify based on the occurrence of 1s.
数组的最小相等和
Find the minimum sum where two arrays become equal after replacing all zeros with positive integers using a greedy strat…
使数组变美的最小增量运算数
Optimize the number of increment operations to make an array beautiful by ensuring subarrays of size 3 or more meet the …
收集所有金币可获得的最大积分
Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.
找到冠军 I
Find Champion I is an easy problem focusing on identifying the strongest team in a tournament using matrix-based compari…
平衡子序列的最大和
Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…
购买物品的最大开销
Maximize spending by carefully choosing the right items across multiple shops over m * n days.
找出强数对的最大异或值 I
Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.
高访问员工
Identify employees with high system access within one-hour periods based on access logs.
最大化数组末位元素的最少操作次数
Minimize the number of operations needed to maximize the last elements of two arrays with specific swaps.
找出强数对的最大异或值 II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
找到 Alice 和 Bob 可以相遇的建筑
Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.
查找包含给定字符的单词
Identify all indices of words containing a specific character using array and string traversal techniques efficiently.
最大化网格图中正方形空洞的面积
Learn how to maximize the area of a square-shaped hole by selectively removing horizontal and vertical bars efficiently …
购买水果需要的最少金币数
Calculate the minimum coins to buy fruits using state transition dynamic programming while handling rewards and purchase…
找到最大非递减数组的长度
Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…
循环移位后的矩阵相似检查
Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…
交换得到字典序最小的数组
Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.
找出峰值
Identify all peaks in a mountain array using direct array enumeration and strict neighbor comparisons efficiently.
需要添加的硬币的最小数量
Determine the minimum number of coins to add so all values up to target are obtainable using a greedy sum approach.
统计感冒序列的数目
Calculate all valid infection sequences in a line by using array positions and combinatorial math efficiently for n peop…
找到两个数组中的公共元素
Quickly find all numbers that appear in both arrays using scanning and hash lookup to handle duplicates efficiently.
最多 K 个重复元素的最长子数组
Find the maximum length subarray where each number appears at most k times using array scanning and hash lookups.
统计已测试设备
Simulate testing devices based on battery percentages to determine how many pass the test operations in sequence.
双模幂运算
Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…
统计最大元素出现至少 K 次的子数组
Find the number of subarrays where the maximum element appears at least k times using a sliding window approach.
统计好分割方案的数目
Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…
找出缺失和重复的数字
Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.
划分数组并满足最大差限制
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…
执行操作使频率分数最大
Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…
统计移除递增子数组的数目 I
Count the number of incremovable subarrays in an array by removing them to create a strictly increasing sequence.
找到最大周长的多边形
Determine the largest perimeter polygon from a set of side lengths using a greedy approach with invariant validation che…
统计移除递增子数组的数目 II
Count the number of incremovable subarrays where removal of the subarray results in a strictly increasing array.
最小数字游戏
The Minimum Number Game involves simulating moves by Alice and Bob on an array, sorting elements and appending them to a…
移除栅栏得到的正方形田地的最大面积
This problem challenges you to calculate the largest square area possible by removing fences from a given rectangular fi…
转换字符串的最小成本 I
This problem asks to calculate the minimum cost to convert a string from source to target using specific character trans…
转换字符串的最小成本 II
Compute the minimum cost to transform source into target using substring replacements with given costs efficiently using…
检查按位或是否存在尾随零
Check if a bitwise OR of two or more numbers has trailing zeros in its binary representation.
大于等于顺序前缀和的最小缺失整数
Find the smallest missing integer greater than the sum of the longest sequential prefix in an array.
使数组异或和等于 K 的最少操作次数
Find the minimum number of operations to make the XOR of an array equal to a given value k by modifying array elements.
对角线最长的矩形的面积
Find the rectangle with the longest diagonal in a 2D array and return its area, prioritizing maximum area on ties.
移除后集合的最多元素数
Maximize a set size by strategically removing half of elements from two arrays using hash lookups and array scanning.
最大频率元素计数
Count Elements With Maximum Frequency is solved by counting each value, tracking the highest count, and summing matching…
将数组分成最小总代价的子数组 I
Divide an array into three contiguous subarrays with minimum cost by leveraging array and sorting principles.
判断一个数组是否可以变为有序
Determine if a given array can be sorted using adjacent swaps restricted by equal set bits in binary representation.
通过操作使数组长度最小
Minimize the length of an integer array through a series of operations, using a greedy approach with modular arithmetic.
将数组分成最小总代价的子数组 II
This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.
子集中元素的最大数量
This problem asks you to find the maximum subset size where each number in the subset follows a specific pattern with ha…
给定操作次数内使剩余元素的或值最小
Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.
三角形类型
Determine the type of triangle from a three-element array using side sums and equality checks efficiently in constant ti…
人员站位的方案数 I
Calculate how many valid pairs of points can be formed on a 2D plane using array and math enumeration techniques efficie…
最大好子数组和
Find the maximum sum of any subarray where the first and last elements differ by exactly k using efficient array scannin…
人员站位的方案数 II
Calculate all valid placements of people on a 2D grid ensuring Alice can fence herself with Bob without enclosing others…
边界上的蚂蚁
Solve the problem of counting how often an ant returns to a boundary based on the steps described in the input array.
找出网格的区域平均强度
Find the Grid of Region Average requires identifying regions in a matrix where pixel differences are below a threshold, …
修改矩阵
Modify the Matrix efficiently by replacing all -1 elements with the maximum in their column using array and matrix opera…
匹配模式数组的子数组数目 I
Count all subarrays in a given integer array that strictly follow a defined numeric pattern using rolling hash checks ef…
回文字符串的最大数量
The problem focuses on maximizing the number of palindromes that can be formed from a given list of words through specif…
匹配模式数组的子数组数目 II
Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.
相同分数的最大操作数目 I
Determine the maximum number of operations in an integer array where each operation must produce the same score.
进行操作使字符串为空
Learn how to systematically apply operations on a string using array scanning and hash lookups to reduce it efficiently.
相同分数的最大操作数目 II
This problem asks to maximize operations on an integer array where all deletions produce the same score using dynamic pr…
修改数组后最大化数组中的连续元素数目
Solve Maximize Consecutive Elements in an Array After Modification by sorting and using state transition DP on value and…
统计前后缀下标对 I
Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.
最长公共前缀的长度
Determine the length of the longest common prefix between two integer arrays using array scanning and hash lookup effici…
出现频率最高的质数
Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…
统计前后缀下标对 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 …
分割数组
Determine if an even-length array can be split into two parts with all distinct elements using hash lookup scanning.
求交集区域内的最大正方形面积
Find the largest square area that can fit inside the intersection of two or more rectangles in a 2D plane.
标记所有下标的最早秒数 I
The problem asks to determine the earliest second to mark all indices in an array using a set of operations.
标记所有下标的最早秒数 II
This problem asks to determine the earliest second at which all indices in an array can be marked using a sequence of op…
超过阈值的最少操作数 I
Count how many numbers are below k, because each such value must be removed in Minimum Operations to Exceed Threshold Va…
超过阈值的最少操作数 II
Calculate the fewest operations to make every array element exceed a threshold using a min-heap simulation strategy effi…
在带权树网络中统计可连接服务器对数目
This problem involves counting pairs of connectable servers in a weighted tree network using binary-tree traversal and D…
最大节点价值之和
Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…
将元素分配到两个数组中 I
Distribute elements from a distinct integer array into two subarrays using a sequential simulation strategy for optimal …
元素和小于等于 k 的子矩阵的数目
Count all submatrices including the top-left element with sum less than k using array and matrix prefix sum strategies.
在矩阵上写出字母 Y 所需的最少操作次数
Find the minimum number of operations to write the letter Y on a grid by altering cell values.
将元素分配到两个数组中 II
Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…
重新分装苹果
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…
数组中的最短非公共子字符串
Find the shortest substring for each string in an array that does not appear in any other string efficiently using hashi…
K 个不相交子数组的最大能量值
Solve Maximum Strength of K Disjoint Subarrays with dynamic programming that tracks segment state, sign changes, and wei…
求出加密整数的和
Compute the sum of encrypted integers by replacing each digit with the largest digit, combining array traversal with dig…
执行操作标记数组中的元素
Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…
求出所有子序列的能量和
Find the sum of the power of all subsequences of an integer array where their sum equals a given number.
拾起 K 个 1 需要的最少行动次数
Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.
最高频率的 ID
Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.
最长公共后缀查询
Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…
或值至少 K 的最短子数组 I
Find the shortest non-empty subarray in nums whose bitwise OR reaches at least k using sliding window efficiently.
得到更多分数的最少关卡数目
Determine the minimum number of levels Alice must play in a binary game array to secure more points than Bob using prefi…
或值至少为 K 的最短子数组 II
Find the length of the shortest subarray where the bitwise OR of all its elements is at least a given value.
求出所有子序列的能量和
Compute the sum of powers for all subsequences of length k using state transition dynamic programming efficiently.
交替子数组计数
Count all alternating subarrays in a binary array efficiently using array patterns and simple mathematical reasoning.
最小化曼哈顿距离
Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.
最长的严格递增或递减子数组
Find the longest subarray in a given array that is either strictly increasing or strictly decreasing.
使数组中位数等于 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 cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…
覆盖所有点的最少矩形数目
Find the minimum number of rectangles needed to cover all points, given constraints on width and position.
访问消失节点的最少时间
Determine the minimum time to visit each node in a disappearing-node graph using arrays, graphs, and priority queues eff…
边界元素是最大值的子数组数目
Count the subarrays where the first and last elements are the largest in the subarray, utilizing binary search over vali…
质数的最大距离
Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…
单面值组合的第 K 小金额
Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…
划分数组得到最小的值之和
Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.
使矩阵满足条件的最少操作次数
This problem asks to find the minimum number of operations on a 2D grid using state transition dynamic programming effic…
构造相同颜色的正方形
Determine if a 3x3 grid can form a 2x2 square of the same color by changing at most one cell efficiently.
直角三角形
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
找出与数组相加的整数 I
Find the integer added to nums1 to make it equal to nums2 using an array-driven strategy.
找出与数组相加的整数 II
Given two arrays nums1 and nums2, determine the integer added to nums1 to make it equal to nums2 after removing two elem…
找出唯一性数组的中位数
Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…
使数组中所有元素相等的最小开销
Compute the minimum cost to make all elements equal using selective operations guided by greedy choices and invariant ch…
判断矩阵是否满足条件
Check if a grid satisfies given conditions by analyzing array and matrix structure with specific checks on values.
正方形中的最多点数
Find the maximum number of points inside a valid square centered at the origin using a scanning and hashing approach.
大数组元素的乘积
Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…
从魔法师身上吸取的最大能量
Maximize your energy by strategically jumping through magicians using array and prefix sum techniques for optimal path c…
矩阵中的最大得分
Maximize the score in a grid by making moves to the bottom or right, using state transition dynamic programming.
找出分数最低的排列
Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…
特殊数组 I
Determine if an array is special by checking alternating parity for every adjacent pair in linear time.
特殊数组 II
Determine whether each subarray meets the special condition of alternating parity for all adjacent elements efficiently …
所有数对中数位差之和
Sum of Digit Differences of All Pairs is a problem that involves counting digit differences in pairs from an array of in…
求出出现两次数字的 XOR 值
Find the XOR of numbers appearing twice by scanning the array and using a hash table for efficient tracking and combinat…
查询数组中元素的出现位置
Determine the position of each requested occurrence of x in nums using a hash table and efficient array scanning.
所有球里面不同颜色的数目
Efficiently track colors on balls using array scanning and hash lookup to return the count of distinct colors after each…
物块放置查询
Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…
优质数对的总数 I
Count all good pairs where an element in nums1 is divisible by a scaled element in nums2 using efficient array scanning.
优质数对的总数 II
Calculate total good pairs by scanning two arrays and using hash lookup to match divisible elements efficiently with k.
不包含相邻元素的子序列的最大和
Compute the maximum sum of a subsequence where no two adjacent elements are selected after each array update efficiently…
无需开会的工作日
Count Days Without Meetings is a problem where you need to count days without scheduled meetings in a given work period.
找到按位或最接近 K 的子数组
Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.
找到连续赢 K 场比赛的第一位玩家
Determine which player first wins k consecutive games using array simulation logic to track ongoing victories efficientl…
求出最长好子序列 I
Find the maximum length of a good subsequence by scanning arrays and using hash lookups for value remapping efficiently.
求出最长好子序列 II
Determine the maximum length of a good subsequence in an integer array using array scanning and hash lookup efficiently.
K 秒后第 N 个元素的值
Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.
执行操作可获得的最大总奖励 I
Optimize the total reward by choosing operations on array indices using state transition dynamic programming techniques …
执行操作可获得的最大总奖励 II
Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …
构成整天的下标对数目 I
Count all pairs in an array where their sum forms a complete day using hash-based counting for efficiency.
构成整天的下标对数目 II
Count the number of valid pairs of hours that form a complete day by checking if their sum is a multiple of 24.
施咒的最大总伤害
Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…
数组中的峰值
Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…
使所有元素都可以被 3 整除的最少操作数
Find the minimum number of operations to make all elements in an array divisible by three.
使二进制数组全部等于 1 的最少操作次数 I
Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…
使二进制数组全部等于 1 的最少操作次数 II
Solve the Minimum Operations to Make Binary Array Elements Equal to One II using state transition dynamic programming ef…
统计逆序对的数目
Count the number of valid permutations satisfying inversion constraints using state transition dynamic programming.
最小元素和最大元素的最小平均值
Solve the Minimum Average of Smallest and Largest Elements problem using two-pointer scanning to track averages effectiv…
包含所有 1 的最小矩形面积 I
Find the smallest rectangle to cover all 1's in a 2D binary matrix, focusing on array and matrix handling.
最大化子数组的总成本
Maximize the total cost of alternating subarrays using dynamic programming to efficiently split an array into optimal su…
包含所有 1 的最小矩形面积 II
Find the minimum area to cover all 1's in a 2D binary grid using three non-overlapping rectangles.
三角形的最大高度
Find the maximum height of a triangle that can be formed using red and blue balls under given constraints.
找出有效子序列的最大长度 I
Find the longest valid subsequence in an array of integers using dynamic programming to handle different patterns of seq…
找出有效子序列的最大长度 II
Determine the maximum length of a valid subsequence using state transition dynamic programming with careful modulo const…
交替组 I
Count all alternating groups in a circular array by tracking tiles with distinct neighbors efficiently using sliding win…
与敌人战斗后的最大分数
Solve the "Maximum Points After Enemy Battles" problem by maximizing points through greedy choices with energy validatio…
交替组 II
Solve the problem of counting alternating groups in a circle of tiles using a sliding window approach.
子数组按位与值为 K 的数目
The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…
统计 X 和 Y 频数相等的子矩阵数量
Count the number of submatrices with equal frequency of 'X' and 'Y' in a 2D character grid.
最小代价构造字符串
This problem asks you to construct a target string using given words at minimal cost using dynamic programming technique…
从链表中移除在数组中存在的节点
Remove nodes from a linked list if their values exist in a given array.
切蛋糕的最小总开销 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…
使差值相等的最少数组改动次数
Minimize changes to make array differences equal by replacing elements within a given range.
网格图操作后的最大分数
Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…
使数组等于目标数组所需的最少操作次数
This problem requires calculating the minimum number of operations to transform one array into another using state trans…
判断是否可以赢得数字游戏
Determine if Alice can guarantee a win in a game by selectively summing single or double-digit numbers from an array.
统计不是特殊数字的数字数量
Count the numbers between two integers that are not special, where special numbers are squares of primes.
判断矩形的两个角落是否可达
Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.
求出胜利玩家的数目
Find how many players in a game win by picking more balls of a single color than their index position.
最少翻转次数使二进制矩阵回文 I
Find the minimum flips to make a binary grid palindromic by scanning with two pointers and tracking symmetry efficiently…
最少翻转次数使二进制矩阵回文 II
The problem asks to flip cells in a binary grid to make its rows and columns palindromic using the minimum number of fli…
设计相邻元素求和服务
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
新增道路查询后的最短距离 I
Solve shortest paths dynamically in a growing graph using BFS, updating distances efficiently after each road addition q…
新增道路查询后的最短距离 II
The problem involves calculating the shortest path from city 0 to city n-1 after each road addition, leveraging greedy c…
交替组 III
Solve Alternating Groups III using array manipulation and a binary indexed tree to track maximal alternating sequences e…
矩阵中的蛇
Solve the Snake in Matrix problem by simulating the snake's movement in a grid based on a series of directional commands…
单调数组对的数目 I
Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.
单调数组对的数目 II
This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…
长度为 K 的子数组的能量值 I
Given an array, find the power of all subarrays of size k using a sliding window approach.
长度为 K 的子数组的能量值 II
Compute the power of all k-size subarrays in an array using sliding window with running state updates efficiently.
放三个车的价值之和最大 I
Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.
放三个车的价值之和最大 II
Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.
超级饮料的最大强化能量
Maximize energy boost from two drinks with a state transition dynamic programming approach.
统计满足 K 约束的子字符串数量 II
Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…
K 次乘运算后的最终数组 I
Solve the problem of determining the final state of an array after multiple multiplication operations using a priority q…
统计近似相等数对 I
Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.
K 次乘运算后的最终数组 II
Optimize the final state of an array after performing k multiplication operations with priority queues.
统计近似相等数对 II
Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.
对 Bob 造成的最少伤害
Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.
第 K 近障碍物查询
Solve the K-th nearest obstacle query problem using array and heap (priority queue) techniques to find distances efficie…
选择矩阵中单元格的最大得分
Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.
查询子数组最大异或值
Solve the Maximum XOR Score Subarray Queries problem using state transition dynamic programming for optimal subarray com…
范围内整数的最大得分
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.
吃掉所有兵需要的最多移动次数
Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…
找到稳定山的下标
Find the indices of stable mountains in an array of mountain heights based on a threshold.
穿越网格图的安全路径
Determine if you can safely traverse a binary grid from top-left to bottom-right using limited health points.
求出数组中最大序列值
Determine the maximum value of a subsequence in an integer array using state transition dynamic programming and bit oper…
最长上升路径的长度
Determine the maximum length of an increasing path in a 2D array using binary search over potential path lengths efficie…
数字小镇中的捣蛋鬼
Find the two numbers that appear twice in a list of integers from 0 to n-1 using array scanning plus hash lookup efficie…
最高乘法得分
The problem requires selecting four indices from an array to maximize a dynamic score with a transition approach.
形成目标字符串需要的最少字符串数 I
Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…
形成目标字符串需要的最少字符串数 II
Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…
举报垃圾信息
Determine if a message contains at least two banned words using array scanning and hash lookup.
移山所需的最少秒数
Determine the minimum seconds required to reduce a mountain to zero height using simultaneous workers efficiently.
替换为数位和以后的最小元素
Replace each number with its digit sum and return the smallest resulting value, using array plus math techniques efficie…
高度互不相同的最大塔高和
Assign heights to towers ensuring each height is unique and the total sum is maximized using greedy sorting techniques.
连接二进制表示可形成的最大数值
Determine the largest number achievable by reordering three integers and concatenating their binary forms efficiently.
构造符合图结构的二维矩阵
This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.
查询排序后的最大公约数
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
构造最小位运算数组 I
Learn how to construct an array minimizing each element while matching given primes using bitwise operations efficiently…
构造最小位运算数组 II
Learn to build the minimum array matching a bitwise OR pattern for each prime in nums, focusing on binary optimization.
从原字符串里进行删除操作的最多次数
Determine the maximum number of characters you can remove from source while keeping pattern as a subsequence using array…
计算子数组的 x-sum I
Compute the x-sum of every subarray of length k efficiently using array scanning combined with hash lookup techniques.
计算子数组的 x-sum II
Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.
使数组非递减的最少除法操作次数
Determine the minimum number of division operations to make an array non-decreasing using a greedy and invariant-based s…
判断 DFS 字符串是否是回文串
Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…
修改后子树的大小
Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…
旅客可以得到的最多点数
Calculate the maximum points a tourist can earn by choosing optimal city moves over k days using state transition DP.
数组的最大因子得分
Calculate the maximum factor score of an integer array by optionally removing one element using LCM and GCD computations…
最大公约数相等的子序列数量
Count all pairs of non-empty subsequences in an integer array whose elements share the same greatest common divisor effi…
到达最后一个房间的最少时间 I
Find Minimum Time to Reach Last Room I challenges you to determine the minimum time to travel in a dungeon with a grid l…
到达最后一个房间的最少时间 II
Calculate the minimum time to reach the last room in a grid with alternating move times using array and graph patterns.
执行操作后元素的最高频率 I
Maximize the frequency of an element in an array after performing a series of operations to find the best possible resul…
执行操作后元素的最高频率 II
Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…
检测相邻递增子数组 I
Check if an array contains two adjacent strictly increasing subarrays of length k using an array-driven approach efficie…
检测相邻递增子数组 II
Find the largest k where two adjacent strictly increasing subarrays of length k exist using binary search techniques.
好子序列的元素之和
Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.
使数组元素等于零
Learn how to transform an integer array to zeros using simulation and directional selection efficiently and reliably.
零数组变换 I
Transform the given integer array into a zero array using range operations, focusing on prefix sum optimization and care…
零数组变换 II
Zero Array Transformation II requires determining the minimum query sequence to convert all array elements to zero using…
最小化相邻元素的最大差值
Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.
两个字符串的切换距离
Find the minimum cost of transforming one string into another, considering operations between characters.
零数组变换 III
Zero Array Transformation III requires removing the minimum number of queries to make all elements zero using greedy val…
最多可收集的水果数目
Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.
最小正和子数组
Find the minimum sum of any subarray of size between l and r with a positive total using efficient sliding window logic.
最小数组和
Solve the Minimum Array Sum problem using dynamic programming by tracking states and operations to minimize the sum of a…
识别数组中的最大异常值
Identify the largest outlier in an integer array using scanning and hash lookup for efficient detection and validation.
使数组的值全部为 K 的最少操作次数
Find the minimum operations to convert an array to all values equal k using array scanning and hash lookup efficiently.
破解锁的最少时间 I
Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…
统计最小公倍数图中的连通块数目
Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…
转换数组
Simulate operations on a circular array to return a transformed result array following specific rules.
用点构造面积最大的矩形 I
Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.
长度可被 K 整除的子数组的最大元素和
Find the maximum sum of a subarray where the length of the subarray is divisible by k.
用点构造面积最大的矩形 II
Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…
按下时间最长的按钮
Determine which button a child pressed the longest using an array-driven strategy to track time differences efficiently.
两天自由外汇交易后的最大货币数
Compute the maximum currency amount after two days using graph traversal and depth-first search for optimal conversions.
统计数组中的美丽分割
Learn to count all valid beautiful splits in an array using state transition dynamic programming efficiently and accurat…
统计符合条件长度为 3 的子数组数目
Determine how many subarrays of length three satisfy a sum condition on their first and third elements in an array.
统计异或值为给定值的路径数目
Count the number of paths in a grid where the XOR of all values along the path equals a given number.
判断网格图能否被切割成块
Determine if an n x n grid can be divided with two horizontal or vertical cuts using rectangle ranges efficiently.
唯一中间众数子序列 I
Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.
使数组元素互不相同所需的最少操作次数
Find the minimum number of operations to make all elements of an array distinct.
执行操作后不同元素的最大数量
Maximize distinct elements in an array by performing at most one operation on each element.
字符相同的最短子字符串 I
Minimize the length of the longest substring with identical characters after at most numOps changes in a binary string.
使每一列严格递增的最少操作次数
Calculate the minimum increments to make each column of a matrix strictly increasing using a greedy invariant approach.
统计特殊子序列的数目
Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…
最长相邻绝对差递减子序列
Find the length of the longest subsequence with non-increasing absolute adjacent differences.
删除所有值为某个元素后的最大子数组和
Maximize Subarray Sum After Removing All Occurrences of One Element involves finding the optimal subarray sum with one a…
最长乘积等价子数组
This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …
收集连续 K 个袋子可以获得的最多硬币数量
Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…
不重叠区间的最大得分
Maximize the score of up to 4 non-overlapping intervals, considering their weight and ensuring no overlap between chosen…
跳过交替单元格的之字形遍历
Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…
机器人可以获得的最大金币数
Find the maximum amount of money a robot can collect while neutralizing robbers on its path in a grid.
统计 K 次操作以内得到非递减子数组的数目
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
循环数组中相邻元素的最大差值
Find the maximum absolute difference between adjacent elements in a circular array using a straightforward array-driven …
将数组变相同的最小代价
Minimize cost to make arrays identical by performing operations with given constraints and a greedy strategy.
最长特殊路径
Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.
变长子数组求和
Calculate the total sum of all elements in subarrays defined for each index in an array, using the array plus prefix sum…
最多 K 个元素的子序列的最值之和
Find the sum of the maximum and minimum elements of subsequences with at most k elements, using dynamic programming.
粉刷房子 IV
Solve the Paint House IV problem using state transition dynamic programming to minimize the painting costs while adherin…
最多 K 个元素的子数组的最值之和
Compute the sum of maximum and minimum values in all subarrays up to size k using efficient stack-based state management…
统计元素和差值为偶数的分区方案
Count the number of partitions with an even sum difference from an array of integers.
统计用户被提及情况
Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…
子数组操作后的最大频率
Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…
最短公共超序列的字母出现频率
Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …
重新安排会议得到最多空余时间 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…
使数组包含目标值倍数的最少增量
This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…
按对角线进行矩阵排序
Sort Matrix by Diagonals groups cells by diagonal, then sorts bottom-left diagonals descending and top-right diagonals a…
将元素分配给有约束条件的组
Assign elements to groups by size constraints with a sieve-like approach to find suitable element matches efficiently.
最大化游戏分数的最小值
Maximizing the minimum score after at most m moves, leveraging binary search and greedy strategies over an array of scor…
好数字之和
The problem asks for the sum of all good numbers in an array based on specific conditions of neighboring elements.
分割正方形 I
Find the minimum y-coordinate of a horizontal line that balances the areas of squares above and below it.
分割正方形 II
Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …
吃披萨
Maximize the total weight gained by optimally eating pizzas in groups of four using greedy selection and invariant valid…
最长 V 形对角线段的长度
Compute the maximum length of a V-shaped diagonal segment in a 2D integer matrix using state transition dynamic programm…
提取至多 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…
将数组按照奇偶性转化
Transform an array by sorting even numbers first, followed by odd numbers.
可行数组的数目
Find the number of possible arrays by leveraging bounds and math in this array-based problem.
移除所有数组元素的最小代价
Find the minimum cost to remove all elements from the array with dynamic programming.
全排列 IV
Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…
找出最大的几近缺失整数
Find the largest almost missing integer in an array where it appears in exactly one subarray of size k.
长度至少为 M 的 K 个子数组之和
Maximize the sum of k non-overlapping subarrays of at least length m using dynamic programming and prefix sums efficient…
水果成篮 II
Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.
选出和最大的 K 个元素
Choose K Elements With Maximum Sum involves sorting and selecting elements based on a specific rule, applying array plus…
水果成篮 III
Fruits Into Baskets III requires placing fruits into baskets efficiently using binary search over the answer space for c…
删除一个冲突对后最大子数组数目
Maximize the count of subarrays after removing one conflicting pair using array traversal and segment tree logic efficie…
不同三位偶数的数目
Given an array of digits, find how many distinct 3-digit even numbers can be formed without repetition of digits and no …
设计电子表格
Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…
删除元素后 K 个字符串的最长公共前缀
Find the longest common prefix length of k strings after removing an element in the array.
最长特殊路径 II
Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…
删除后的最大子数组元素和
Maximize the sum of a subarray after performing deletions, ensuring elements remain unique.
距离最小相等元素查询
Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.
属性图
Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…
酿造药水需要的最少总时间
This problem involves calculating the minimum time required for wizards to brew potions based on their skills and mana u…
使数组元素都变为零的最少操作次数
Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…
将数组分割为子数组的最小代价
Optimize array splits with dynamic programming to minimize costs for the Minimum Cost to Divide Array Into Subarrays pro…
操作后最大活跃区段数 II
Maximize the number of active sections in a binary string with at most one trade.
到达每个位置的最小费用
Calculate the minimum swap costs to reach each position in a line using a precise array-driven strategy for efficiency.
使 K 个子数组内元素相等的最少操作数
Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…
移除最小数对使数组有序 I
This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.
设计路由器
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
最大化交错和为 K 的子序列乘积
Find the maximum product of a subsequence in an array with an alternating sum equal to a given target.
移除最小数对使数组有序 II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
使数组和能被 K 整除的最少操作次数
This problem asks you to find the minimum operations to make the sum of an array divisible by a given integer k.
不同 XOR 三元组的数目 I
Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…
不同 XOR 三元组的数目 II
Count all unique XOR results from triplets in an integer array using array traversal and bit manipulation techniques eff…
带权树中的最短路径
Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.
执行指令后的得分
Simulate a series of add and jump instructions on arrays to compute the final score efficiently using array scanning and…
非递减数组的最大长度
Determine the maximum size of a non-decreasing array by replacing subarrays with their maximum values efficiently.
求出数组的 X 值 I
Determine the x-value of an array using state transition dynamic programming to count valid prefix-suffix operations eff…
求出数组的 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…
找到最常见的回答
Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…
统计水平子串和垂直子串重叠格子的数目
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…
有向无环图中合法拓扑排序的最大利润
Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…
统计被覆盖的建筑
Determine how many buildings in an n x n city are completely surrounded using array scanning and hash lookup efficiently…
针对图的路径存在性查询 I
Determine if paths exist between nodes using array scanning and hash lookups for efficient component checks in graphs.
判断连接可整除性
Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …
针对图的路径存在性查询 II
Solve path existence queries in a graph using binary search on the answer space, focusing on sorted nodes and maximum di…
填充特殊网格
Fill a Special Grid uses recursive divide-and-conquer to populate a 2^n x 2^n matrix with sequential integers uniquely i…
合并得到最小旅行时间
Minimize the total travel time by merging road signs, using dynamic programming to manage state transitions efficiently.
魔法序列的数组乘积之和
Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…
将所有元素变为 0 的最少操作次数
Calculate the fewest operations to turn all numbers in an array to zero using subarray minimum elimination strategy.
子树反转和
This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…
等和矩阵分割 I
Determine if an m x n matrix grid can be split into two non-empty sections with equal sums by making a single horizontal…
等和矩阵分割 II
Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.
数位和等于下标的最小下标
Find the smallest index in an array where the sum of the digits equals the index.
数位和排序需要的最小交换次数
Calculate the minimum swaps to sort an array by digit sum, ensuring correct order with tiebreaker values for efficiency.
网格传送门旅游
Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.
包含要求路径的最小带权子图 II
Solve the Minimum Weighted Subgraph With the Required Paths II problem by leveraging binary-tree traversal and efficient…
给边赋权值的方案数 II
This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.
折扣价交易股票的最大利润
Solve the Maximum Profit from Trading Stocks with Discounts problem using binary-tree traversal and dynamic state tracki…
等积子集的划分方案
Determine if you can partition an array into two subsets with equal product using recursion and bit manipulation.
子矩阵的最小绝对差
Find the minimum absolute difference in each k x k submatrix within a given 2D grid using array and sorting techniques.
清理教室的最少移动
Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.
分割数组后不同质数的最大数目
Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…
选择不同 X 值三元组使 Y 值之和最大
Select three distinct x-values from arrays to maximize the sum of their corresponding y-values efficiently using hashing…
买卖股票的最佳时机 V
Maximize profit from stock trades with at most k transactions using state transition dynamic programming for precise dec…
最大子数组 GCD 分数
Maximize Subarray GCD Score focuses on maximizing a subarray's score by using at most k doubling operations on an array …
最大好子树分数
Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…
数组元素相等转换
Transform Array to All Equal Elements requires careful greedy choices and validating invariants to achieve uniformity ef…
统计计算机解锁顺序排列数
Calculate the total valid unlocking sequences for computers based on their complexity using array and combinatorics logi…
统计极差最大为 K 的分割方式数
Count the number of valid ways to partition an array into contiguous segments where max-min difference is at most k.
统计特殊三元组
Count Special Triplets requires scanning an array while tracking counts of previous and next values efficiently with has…
子序列首尾元素的最大乘积
Maximize the product of the first and last elements of any subsequence of size m in an integer array.
树中找到带权中位节点
Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…
最小相邻交换至奇偶交替
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.
计数质数间隔平衡子数组
Count the number of prime-gap balanced subarrays in an integer array using sliding window techniques and running state u…
第 K 小的路径异或和
This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…
检查元素频次是否为质数
Check if any element in the array has a prime frequency count, leveraging array scanning and hash table lookup.
硬币面值还原
Recover coin denominations from a numWays array using state transition dynamic programming to reconstruct valid sets eff…
使叶子路径成本相等的最小增量
Find the minimum number of increments needed to equalize leaf path scores in a tree with different node costs.
所有人渡河所需的最短时间
Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.
相邻字符串之间的最长公共前缀
Given an array of strings, find the longest common prefix length between adjacent strings after removals at each index.
划分数组得到最小 XOR
Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…
交替方向的最小路径代价 II
This problem focuses on finding the minimum cost path with alternating directions in a grid using dynamic programming.
数组的最小稳定性因子
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
优惠券校验器
The Coupon Code Validator problem requires filtering and sorting coupons based on specific criteria for validity.
电网维护
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
根据质数下标分割数组
Split Array by Prime Indices challenges you to separate elements at prime positions and minimize the absolute sum differ…
总价值可以被 K 整除的岛屿数目
Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.
恢复网络路径
Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.
统计梯形的数目 I
Given a list of distinct points, count the number of unique horizontal trapezoids that can be formed by selecting four p…
位计数深度为 K 的整数数目 II
This problem challenges you to efficiently calculate the number of integers with popcount-depth equal to K using array a…
统计梯形的数目 II
Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…
划分数组得到最大异或运算和与运算之和
Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.