训练重点
强调模式识别、状态设计和复杂度平衡。
建议节奏
每轮 3-5 题,先口述思路再写代码,最后复盘错误路径。
搭配建议
结合模式页和题型页同步练,能更快形成可迁移能力。
两数相加
Add Two Numbers requires careful linked-list pointer manipulation to sum digits while handling carries efficiently in in…
无重复字符的最长子串
Find the length of the longest substring without repeating characters using a sliding window and hash map to track state…
最长回文子串
Find the longest contiguous palindromic substring in a given string using dynamic programming and two-pointer expansion …
Z 字形变换
Convert a string into a zigzag pattern across multiple rows and read it line by line efficiently for string manipulation…
整数反转
Reverse Integer challenges you to invert the digits of a signed 32-bit integer, handling overflow and negative values ca…
字符串转换整数 (atoi)
Convert a string to a 32-bit signed integer by carefully parsing characters, handling signs, and ignoring invalid traili…
盛最多水的容器
Find two vertical lines that can form a container with the most water in a given array of heights.
整数转罗马数字
Convert a given integer to its Roman numeral representation using hash table mapping and decimal place math operations e…
三数之和
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.
电话号码的字母组合
Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…
四数之和
The 4Sum problem requires finding all unique quadruplets in an array that sum to a specific target value.
删除链表的倒数第 N 个结点
Remove the nth node from the end of a linked list using a two-pointer approach to solve efficiently.
括号生成
Generate Parentheses requires generating all valid combinations of parentheses with given pairs using backtracking and s…
两两交换链表中的节点
Learn how to swap every adjacent linked-list pair by rewiring nodes safely without changing values or breaking the remai…
两数相除
Solve Divide Two Integers by turning repeated subtraction into bit-shifted chunk subtraction with careful sign and overf…
下一个排列
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.
有效的数独
Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …
外观数列
Count and Say requires building the nth sequence term by iteratively applying a run-length encoding on strings of digits…
组合总和
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…
字符串相乘
Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…
跳跃游戏 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.
Pow(x, n)
Calculate x to the power n efficiently using recursion and exponentiation, handling negative powers and large inputs saf…
最大子数组和
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…
旋转链表
Rotate a singly linked list to the right by k positions using careful pointer manipulation and two-pointer traversal tec…
不同路径
Calculate the number of unique paths for a robot to move on an m x n grid with only right and down movements.
不同路径 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.
简化路径
Simplify a Unix-style path by transforming it into its canonical form using stack-based state management.
编辑距离
Determine the minimum number of insertions, deletions, or replacements to transform one string into another using dynami…
矩阵置零
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 combinations of k numbers from the range [1, n] using backtracking and pruning.
子集
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…
删除排序链表中的重复元素 II
Remove duplicates from a sorted linked list, leaving only distinct values, and return the modified list in sorted order.
分隔链表
Partition a linked list such that all nodes less than x come before nodes greater than or equal to x while preserving re…
格雷编码
Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.
子集 II
Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…
解码方法
Decode Ways is a dynamic programming problem focused on decoding a numeric string to letters using specific mappings.
反转链表 II
Reverse a segment of a singly linked list from position left to right using precise pointer manipulation techniques.
复原 IP 地址
Restore all valid IP addresses from a string using backtracking with pruning, avoiding invalid segments or leading zeros…
不同的二叉搜索树 II
Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.
不同的二叉搜索树
Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.
交错字符串
The Interleaving String problem requires determining if a string can be formed by interleaving two others, utilizing dyn…
验证二叉搜索树
Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…
恢复二叉搜索树
Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…
二叉树的层序遍历
Perform a level order traversal on a binary tree using BFS to return node values level by level.
二叉树的锯齿形层序遍历
Traverse a binary tree in zigzag level order, alternating directions at each depth using BFS and state tracking techniqu…
从前序与中序遍历序列构造二叉树
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…
二叉树的层序遍历 II
Return a bottom-up level order traversal of a binary tree, processing nodes left to right while tracking each level accu…
有序链表转换二叉搜索树
Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…
路径总和 II
Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.
二叉树展开为链表
Flatten a binary tree into a right-skewed linked list by manipulating pointers following a pre-order traversal, handling…
填充每个节点的下一个右侧节点指针
Connect each node across every level by reusing established next links to traverse a perfect binary tree without extra q…
填充每个节点的下一个右侧节点指针 II
Populate each next pointer in a binary tree to its immediate right node, handling nulls and uneven levels efficiently us…
三角形最小路径和
Given a triangle, return the minimum path sum from top to bottom, moving to adjacent numbers in the row below.
买卖股票的最佳时机 II
Maximize stock profit by using a greedy approach to buy and sell multiple times, with state transition dynamic programmi…
最长连续序列
Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.
求根节点到叶节点数字之和
Calculate the sum of all root-to-leaf numbers in a binary tree where each path represents a number.
被围绕的区域
Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.
分割回文串
Find all possible palindrome partitioning of a string using backtracking and dynamic programming.
克隆图
Clone Graph involves cloning a graph using DFS, focusing on graph traversal and neighbor management using hash tables.
加油站
The Gas Station problem requires finding the starting station index for a full circular trip with gas stations and costs…
只出现一次的数字 II
Find the single element in an array where every other element appears three times, using bit manipulation and constant s…
随机链表的复制
This problem requires copying a linked list where each node has a random pointer in addition to the next pointer.
单词拆分
Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…
环形链表 II
Identify the start of a cycle in a linked list using pointer manipulation, efficiently handling edge cases without modif…
重排链表
Reorder List requires careful pointer manipulation in a singly linked list to interleave nodes from the ends without alt…
LRU 缓存
Implement an efficient LRU Cache using hash table and doubly-linked list to achieve O(1) operations for get and put.
对链表进行插入排序
Sort a singly linked list using insertion sort by carefully manipulating pointers to maintain a sorted order efficiently…
排序链表
Sort List requires sorting a singly linked list efficiently using pointer manipulation and merge sort for optimal perfor…
逆波兰表达式求值
Compute the result of an arithmetic expression in Reverse Polish Notation using a stack to manage operands efficiently.
反转字符串中的单词
Reverse Words in a String requires reordering words using precise two-pointer scanning with careful space handling for e…
乘积最大子数组
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.
最小栈
Design a stack with O(1) operations to push, pop, retrieve the top element, and get the minimum element in constant time…
寻找峰值
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…
比较版本号
Compare two version numbers by checking their individual revisions, considering missing revisions as zero, using a two-p…
分数到小数
Convert a fraction into a decimal, handling repeating decimals with parentheses around the repeating part.
两数之和 II - 输入有序数组
Solve the Two Sum II problem efficiently using binary search over a valid answer space in a sorted array.
阶乘后的零
Given a number n, find how many trailing zeroes are in n! using a math-driven approach.
二叉搜索树迭代器
Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…
最大数
The problem asks to arrange integers to form the largest possible number, focusing on greedy algorithms and string handl…
重复的DNA序列
Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.
轮转数组
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 …
二叉树的右视图
The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…
岛屿数量
Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…
数字范围按位与
Use shared high bits and bit clearing to solve Bitwise AND of Numbers Range without scanning every value.
计数质数
Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.
课程表
Determine if all courses can be completed by analyzing prerequisite dependencies using indegree tracking and topological…
实现 Trie (前缀树)
This problem requires designing a Trie (Prefix Tree) to efficiently store and query strings using hash table concepts fo…
长度最小的子数组
Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.
课程表 II
Solve the 'Course Schedule II' problem using graph indegree and topological ordering, utilizing DFS or BFS to find the c…
添加与搜索单词 - 数据结构设计
Build a WordDictionary supporting dynamic word addition and search with wildcard matching efficiently using Trie and DFS…
打家劫舍 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.
最大正方形
Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.
矩形面积
Calculate the total area covered by two rectangles using geometry, handling overlaps and avoiding double counting effici…
基本计算器 II
Basic Calculator II evaluates a mathematical expression with operators and integers, handling basic arithmetic with prec…
多数元素 II
Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…
二叉搜索树中第 K 小的元素
Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.
二叉搜索树的最近公共祖先
Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…
二叉树的最近公共祖先
Identify the lowest common ancestor of two nodes in a binary tree using traversal and state tracking techniques efficien…
删除链表中的节点
Delete Node in a Linked List focuses on pointer manipulation to delete a node in a singly linked list without access to …
除了自身以外数组的乘积
Solve the 'Product of Array Except Self' problem by calculating the product of all elements except self for each index e…
搜索二维矩阵 II
Efficiently search for a target in a 2D matrix using binary search and matrix properties.
为运算表达式设计优先级
Solve Different Ways to Add Parentheses by splitting on each operator and memoizing every subexpression result list.
只出现一次的数字 III
Find the two unique numbers in an array where all other numbers appear exactly twice using bit manipulation efficiently.
丑数 II
Find the nth ugly number, where ugly numbers have prime factors limited to 2, 3, and 5.
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.
完全平方数
Perfect Squares asks for the least number of perfect squares summing to a given integer n using dynamic programming or B…
窥视迭代器
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 Bulls and Cows problem using hash tables and string manipulation to track exact and misplaced digits.
最长递增子序列
Solve the Longest Increasing Subsequence problem using dynamic programming and binary search to efficiently find the sub…
二维区域和检索 - 矩阵不可变
Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.
累加数
Additive Number is solved by trying the first two splits, then pruning aggressively while verifying each required sum in…
区域和检索 - 数组可修改
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…
最小高度树
Identify all roots of a tree that produce minimum height using graph indegree analysis and topological trimming.
超级丑数
Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …
去除重复字母
Remove duplicate letters from a string to produce the lexicographically smallest result using stack-based state manageme…
最大单词长度乘积
The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…
灯泡开关
Bulb Switcher challenges you to find how many bulbs remain on after n toggling rounds using a math-based insight.
零钱兑换
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.
奇偶链表
Reorder a singly linked list by grouping odd-indexed nodes first, followed by even-indexed nodes while preserving relati…
验证二叉树的前序序列化
Determine if a given string correctly represents a binary tree preorder traversal using state tracking and slot counting…
递增的三元子序列
Identify if an array contains a strictly increasing triplet by maintaining a running minimal and middle value efficientl…
打家劫舍 III
Maximize the loot by robbing non-adjacent houses in a binary tree structure using dynamic programming and DFS.
扁平化嵌套列表迭代器
Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.
整数拆分
Break an integer into the sum of positive integers to maximize the product using dynamic programming.
前 K 个高频元素
Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.
设计推特
Design Twitter requires implementing post, follow, unfollow, and news feed retrieval using linked-list pointer manipulat…
统计各位数字都不同的数字个数
The problem asks to count numbers with unique digits from 0 to 10^n using dynamic programming, math, and backtracking te…
水壶问题
Determine if two jugs with given capacities can measure an exact target amount using math and DFS strategies efficiently…
最大整除子集
Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…
两整数之和
Solve the Sum of Two Integers problem using bit manipulation and math to avoid using the operators + and -.
超级次方
Compute large exponentiations efficiently using modular arithmetic and divide-and-conquer techniques for this Super Pow …
查找和最小的 K 对数字
Find K Pairs with Smallest Sums combines arrays and heap usage to select the smallest sum pairs efficiently.
猜数字大小 II
Minimize the maximum cost of guessing a number in a dynamic guessing game using optimal strategies.
摆动序列
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.
链表随机节点
Select a random node from a singly linked list ensuring uniform probability using efficient pointer techniques and reser…
打乱数组
Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…
迷你语法分析器
Deserialize a nested list string using stack-based state management, handling integers and nested lists with depth-first…
字典序排数
Generate all numbers from 1 to n in lexicographical order using a depth-first search pattern optimized with trie logic f…
文件的最长绝对路径
Find the length of the longest absolute file path in a filesystem string using stack-based depth tracking efficiently.
消除游戏
Elimination Game uses a systematic removal of numbers with alternating left-right passes, solvable with math and recursi…
UTF-8 编码验证
Determine if an integer array represents valid UTF-8 encoding based on its byte sequences using bit manipulation.
字符串解码
Decode a nested encoded string using stack-based state management, handling repeated patterns efficiently with recursion…
至少有 K 个重复字符的最长子串
Find the length of the longest substring where every character appears at least k times using sliding window and divide-…
旋转函数
Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.
整数替换
Find the minimum number of operations to reduce a number to 1 by applying specific operations, using state transition dy…
随机数索引
Random Pick Index involves selecting a random index of a target number in an array with possible duplicates.
除法求值
Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.
第 N 位数字
Given n, efficiently find the nth digit in the infinite integer sequence using a binary search over valid positions.
移掉 K 位数字
Remove K Digits requires selecting which digits to drop using a monotonic stack for the smallest possible integer result…
根据身高重建队列
Reconstruct a queue based on the given heights and the number of taller people in front, using sorting and binary indexe…
等差数列划分
Count the number of arithmetic subarrays in a given integer array using dynamic programming.
分割等和子集
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.
从英文中重建数字
This problem asks you to reconstruct digits from an out-of-order English string using hash counting and mathematical ded…
替换后的最长重复字符
Find the length of the longest substring after at most k replacements using a sliding window and character count trackin…
建立四叉树
Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.
N 叉树的层序遍历
Perform a level order traversal on an n-ary tree, capturing nodes by depth using breadth-first search with careful state…
扁平化多级双向链表
Flatten a multilevel doubly linked list by correctly updating next, prev, and child pointers to create a single-level se…
最小基因变化
Determine the minimum number of single-character gene mutations to reach the target gene using BFS and a hash table look…
无重叠区间
Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…
路径总和 III
Path Sum III challenges you to count paths in a binary tree that sum to a given target value with downward traversal.
找到字符串中所有字母异位词
Find all starting indices of p's anagrams in s using sliding window and hash table approach.
数组中重复的数据
Find all integers that appear twice in an array with O(n) time and constant space complexity.
压缩字符串
Compress a character array in-place by converting consecutive repeated characters into counts using two-pointer scanning…
两数相加 II
Add Two Numbers II involves summing two numbers represented as linked lists and returning the result as a new linked lis…
回旋镖的数量
Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.
序列化和反序列化二叉搜索树
Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.
删除二叉搜索树中的节点
Delete Node in a BST hinges on removing one target while preserving in-order ordering through carefully chosen subtree r…
根据字符出现频率排序
Sort Characters By Frequency requires counting characters efficiently and rearranging a string in descending frequency o…
用最少数量的箭引爆气球
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.
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 if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…
环绕字符串中唯一的子字符串
Solve the 'Unique Substrings in Wraparound String' problem using dynamic programming with a state transition approach.
验证IP地址
Determine whether a given string is a valid IPv4 or IPv6 address using a precise string-driven validation strategy.
用 Rand7() 实现 Rand10()
Generate uniform random numbers from 1 to 10 using only rand7(), applying rejection sampling for consistent probability …
火柴拼正方形
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.
在圆内随机生成点
Generate Random Point in a Circle requires creating a uniform random point inside a circle using math and geometry princ…
神奇字符串
Count the number of '1's in the first n characters of a magical string using two-pointer scanning and invariant tracking…
预测赢家
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.
目标和
Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…
非重叠矩形中的随机点
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.
下一个更大元素 II
Solve the Next Greater Element II problem by using a stack-based state management approach for circular arrays.
出现次数最多的子树元素和
Identify the most frequent subtree sum in a binary tree using DFS and hash table tracking for efficient state management…
找树左下角的值
Find the leftmost value in the last row of a binary tree using efficient traversal strategies.
在每个树行中找最大值
Find the largest value in each row of a binary tree using depth-first or breadth-first search techniques.
最长回文子序列
Find the length of the longest palindromic subsequence in a string using precise state transition dynamic programming.
零钱兑换 II
Calculate the number of unique coin combinations to reach a target amount using state transition dynamic programming eff…
随机翻转矩阵
Design an optimized algorithm to randomly flip an index in a matrix, using hash tables and math for efficient random sel…
最长特殊序列 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.
TinyURL 的加密与解密
Design a class that encodes and decodes URLs using a URL shortening approach based on hash tables and strings.
复数乘法
This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…
把二叉搜索树转换为累加树
Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.
最小时间差
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…
省份数量
Solve Number of Provinces by scanning the adjacency matrix and launching DFS once per unvisited city component.
最优除法
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.
下一个更大元素 III
Find the next greater integer using the same digits as a given number with precise two-pointer scanning and invariant tr…
四叉树交集
Compute the logical OR of two binary matrices represented as Quad-Trees using recursive tree traversal and state propaga…
和为 K 的子数组
Count the total number of contiguous subarrays in an integer array that sum exactly to a target value k using optimized …
数组嵌套
Find the longest nested set in a permutation array using a depth-first traversal, handling cycles efficiently for medium…
字符串的排列
Check if a string contains a permutation of another string using two-pointer scanning and hash table techniques.
出界的路径数
Calculate the number of ways a ball can exit a grid using dynamic programming with state transitions for every move comb…
最短无序连续子数组
Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.
两个字符串的删除操作
Find the minimum number of steps to make two strings equal by deleting characters, using dynamic programming.
分数加减运算
Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…
有效的正方形
Determine if four given 2D points form a valid square using geometric distance checks and vector validation techniques.
根据二叉树创建字符串
Given a binary tree, construct a string representation based on preorder traversal while adhering to specific formatting…
在系统中查找重复文件
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…
在二叉树中增加一行
The problem requires adding a row of nodes to a binary tree at a specified depth.
数组列表中的最大距离
Maximum Distance in Arrays uses a greedy running minimum and maximum from previous arrays to validate cross array distan…
平方数之和
Given a non-negative integer c, determine if there are two integers whose squares sum to c.
函数的独占时间
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.
求解方程
Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.
设计循环双端队列
Design and implement a circular deque using linked-list pointer manipulation, ensuring efficient insertion and deletion …
最长数对链
Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…
回文子串
Count all palindromic substrings in a given string using state transition dynamic programming for efficient evaluation.
单词替换
Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…
Dota2 参议院
The Dota2 Senate problem involves simulating voting rounds between Radiant and Dire senators until one party wins, using…
两个键的键盘
Minimize the number of operations to get exactly 'n' characters on the screen using two operations: Copy All and Paste.
寻找重复的子树
Identify all duplicate subtrees in a binary tree by efficiently tracking structure and values with depth-first traversal…
最大二叉树
Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …
输出二叉树
Print Binary Tree requires arranging a binary tree into a visually structured matrix using precise traversal and positio…
找到 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.
二叉树最大宽度
Determine the maximum width of a binary tree by calculating the width of each level and considering the positions of the…
非递减数列
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…
修剪二叉搜索树
Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.
最大交换
Given an integer, swap at most two digits once to produce the largest possible number using greedy digit selection.
灯泡开关 Ⅱ
Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.
最长递增子序列的个数
This problem challenges you to find the number of longest increasing subsequences in a given array of integers.
实现一个魔法字典
Design a Magic Dictionary to allow searching with one-character modifications, using Hash Table and String techniques.
键值映射
Design and implement a data structure that supports efficient insertion and sum queries based on string prefixes.
有效的括号字符串
Solve the Valid Parenthesis String problem by leveraging state transition dynamic programming to handle parentheses and …
冗余连接
Identify and remove the redundant edge that causes a cycle in a graph starting as a tree.
重复叠加字符串匹配
Find the minimum number of repetitions of string a to make string b a substring of the repeated string a.
最长同值路径
Find the longest path in a binary tree where all nodes share the same value using depth-first search efficiently.
骑士在棋盘上的概率
Calculate the probability that a knight remains on an n x n chessboard after making exactly k moves using dynamic progra…
员工的重要性
Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…
前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.
划分为k个相等的子集
Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…
二叉搜索树中的插入操作
Insert a value into a Binary Search Tree while maintaining the BST properties, focusing on tree traversal and state trac…
设计链表
Implement a custom linked list supporting head, tail, index insertions, retrieval, and deletions efficiently with pointe…
两个字符串的最小ASCII删除和
This problem focuses on minimizing the ASCII delete sum for two strings by using dynamic programming to find the lowest …
乘积小于 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…
最长重复子数组
Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.
词典中最长的单词
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.
分隔链表
Efficiently split a singly linked list into k consecutive parts, balancing sizes while preserving the original node orde…
我的日程安排表 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…
小行星碰撞
Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…
单调递增的数字
Determine the largest number less than or equal to n with digits in non-decreasing order using a greedy, invariant-drive…
每日温度
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…
网络延迟时间
Find the minimum time for a signal to travel to all nodes in a directed graph or determine if it's impossible.
打开转盘锁
Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.
到达终点数字
Determine the minimum number of moves to reach a target on an infinite number line using step increments, leveraging bin…
金字塔转换矩阵
The Pyramid Transition Matrix problem requires determining whether a pyramid can be formed with given blocks and valid p…
划分字母区间
Partition a string into maximal parts so that each letter appears in only one segment, using two-pointer scanning.
最大加号标志
Find the largest axis-aligned plus sign in a binary grid with some mines using dynamic programming.
重构字符串
Reorganize a string so that no two adjacent characters are the same, if possible, using a greedy approach.
最多能完成排序的块
The Max Chunks To Make Sorted problem requires you to split an array into the maximum number of chunks that can be sorte…
全局倒置与局部倒置
Determine if every global inversion in a permutation array is also a local inversion using array and math logic efficien…
在 LR 字符串中交换相邻字符
Transform one string into another by swapping adjacent 'L' and 'R' characters in a sequence of moves.
第K个语法符号
Determine the K-th symbol in a recursively generated grammar table using math and bit manipulation patterns efficiently.
森林中的兔子
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
字母大小写全排列
Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.
判断二分图
Determine whether an undirected graph can be split into two independent sets using DFS, BFS, or Union Find patterns.
第 K 个最小的质数分数
Find the k-th smallest fraction from a sorted array of unique primes using a binary search over the answer space.
K 站中转内最便宜的航班
Find the cheapest flight from a source to a destination with at most K stops using graph traversal techniques efficientl…
旋转数字
Count all integers from 1 to n that transform into a different valid number when each digit is rotated 180 degrees using…
逃脱阻碍者
Escape The Ghosts tests your ability to analyze movements in an infinite grid while racing against ghost positions using…
多米诺和托米诺平铺
Calculate the number of ways to tile a 2xN board using dominoes and trominoes with precise state transitions.
自定义字符串排序
Sort the string `s` according to a custom order defined by string `order`.
匹配子序列的单词数
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 all paths in a directed acyclic graph (DAG) from source to target using depth-first search and backtracking.
香槟塔
Compute champagne levels in a pyramid of glasses using state transition dynamic programming for accurate distribution tr…
找到最终的安全状态
Solve the problem of finding eventual safe states in a directed graph using depth-first search and topological sorting.
保持城市天际线
Maximize building heights in a city grid without changing the skyline, using greedy selection constrained by row and col…
分汤
Compute the probability that soup A empties before soup B using state transition dynamic programming efficiently.
情感丰富的文字
Expressive Words challenges you to determine if a word can be transformed into a given string by extending groups of rep…
子域名访问计数
The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…
最大平均值和的分组
Maximize the sum of averages by partitioning an integer array into at most k contiguous subarrays using dynamic programm…
二叉树剪枝
Binary Tree Pruning removes subtrees not containing a 1, applying binary-tree traversal with state tracking.
模糊坐标
Find all valid 2D coordinate possibilities for an ambiguous input string using backtracking and pruning techniques.
链表组件
Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…
单词的压缩编码
Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…
翻转卡片游戏
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…
隐藏个人信息
This problem requires masking sensitive parts of emails and phone numbers using a precise string-driven strategy efficie…
字符串中的查找与替换
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.
新 21 点
Calculate the probability Alice reaches at most n points using state transition dynamic programming efficiently.
推多米诺
In the "Push Dominoes" problem, you simulate the falling dominoes based on their initial states and determine their fina…
矩阵中的幻方
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
钥匙和房间
Determine if all rooms can be visited given keys distributed across a set of interconnected locked rooms using graph tra…
将数组拆分成斐波那契序列
This problem challenges you to split a string into a Fibonacci-like sequence using backtracking and pruning.
数组中的最长山脉
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…
喧闹和富有
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…
考场就座
Simulate an exam room where each student chooses a seat maximizing distance to others, using design plus heap structures…
括号的分数
Calculate the score of a balanced parentheses string using stack-based state management for an optimal solution.
镜面反射
Given a square room with mirrors, find which receptor a laser ray will hit first based on two integers, p and q.
翻转矩阵后的得分
Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.
二叉树中所有距离为 K 的结点
Find all nodes at distance K from a target node in a binary tree using various tree traversal techniques.
具有所有最深节点的最小子树
Find the smallest subtree that contains all the deepest nodes in a binary tree.
回文质数
The Prime Palindrome problem asks for the smallest prime palindrome greater than or equal to a given integer.
重新排序得到 2 的幂
Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.
优势洗牌
Maximize the advantage of nums1 over nums2 using a two-pointer greedy strategy, carefully tracking which elements beat o…
最长的斐波那契子序列的长度
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.
索引处的解码字符串
Decode the string and find the k-th letter efficiently using stack-based state management in this problem.
救生艇
Find the minimum number of boats required to save all people, using a two-pointer approach for efficient pairing.
螺旋矩阵 III
Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…
可能的二分法
Determine if a group of n people with mutual dislikes can be split into two non-conflicting groups using graph traversal…
根据前序和后序遍历构造二叉树
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 …
特殊等价字符串组
Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.
所有可能的真二叉树
Generate all possible full binary trees with n nodes, focusing on dynamic programming and binary tree traversal.
子数组按位或操作
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…
股票价格跨度
Design an efficient algorithm using stacks to calculate the stock span for daily price quotes.
水果成篮
The Fruit Into Baskets problem requires finding the maximum number of fruits you can pick from a row of trees under spec…
子数组的最小值之和
Calculate the sum of minimum values across all subarrays of a given array modulo 10^9 + 7.
蛇梯棋
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.
分割数组
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 …
完全二叉树插入器
Implement a data structure to insert nodes into a complete binary tree while preserving its completeness efficiently.
使括号有效的最少添加
Compute the minimum insertions needed to make a parentheses string valid using efficient stack-based state tracking tech…
三数之和的多种可能
Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…
将字符串翻转到单调递增
Minimize the number of flips needed to make a binary string monotone increasing using dynamic programming.
和相同的二元子数组
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.
骑士拨号器
Solve the Knight Dialer problem using state transition dynamic programming to efficiently calculate valid number paths f…
重新排列日志文件
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.
使数组唯一的最小增量
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 the number of stones removed from a 2D plane using graph traversal and DFS.
令牌放置
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.
翻转等价二叉树
Determine if two binary trees are flip equivalent by recursively swapping subtrees.
二倍数对数组
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…
N 天后的牢房
Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…
二叉树的完全性检验
Determine if a binary tree is complete by verifying its node structure and leftmost placement in the last level.
由斜杠划分区域
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
最大宽度坡
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…
连续差相同的数字
Generate all n-digit numbers where consecutive digits differ by k using efficient backtracking and BFS techniques.
煎饼排序
Sort an array using pancake flips, leveraging two-pointer scanning and invariant tracking to iteratively position the la…
强整数
Find all integers that can be expressed as x^i + y^j up to a given bound using a Hash Table plus Math approach.
翻转二叉树以匹配先序遍历
Determine the minimum set of nodes to flip in a binary tree so its pre-order traversal matches a given voyage sequence.
最接近原点的 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.
最长湍流子数组
Find the length of the longest subarray where element comparisons alternate, using state transition dynamic programming …
在二叉树中分配硬币
Minimize the number of moves needed to distribute coins in a binary tree so that each node has exactly one coin.
基于时间的键值存储
Implement a time-based key-value store that retrieves the latest value at a given timestamp using efficient binary searc…
最低票价
Solve the Minimum Cost For Tickets problem using state transition dynamic programming for optimal travel ticket purchase…
不含 AAA 或 BBB 的字符串
Solve the problem of constructing a string without consecutive 'AAA' or 'BBB' by applying a greedy approach with invaria…
查询后的偶数和
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…
从叶结点开始的最小字符串
Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…
等式方程的可满足性
Determine if it's possible to assign values to variables such that all equations are satisfied based on equality and ine…
坏了的计算器
Compute the minimum operations to transform startValue into target using doubling and decrementing, leveraging a greedy …
腐烂的橘子
Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.
最大二叉树 II
The Maximum Binary Tree II problem requires building a binary tree by inserting a value into a maximum binary tree while…
检查替换后的词是否有效
Determine if a string can be built from repeated 'abc' insertions using stack-based state management, verifying sequence…
最大连续1的个数 III
Find the longest consecutive ones in a binary array by optimally flipping at most k zeros using sliding window technique…
笨阶乘
Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…
行相等的最少多米诺旋转
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…
最佳观光组合
Compute the maximum sightseeing score efficiently using state transition dynamic programming and single-pass array itera…
可被 K 整除的最小整数
Find the length of the smallest positive integer divisible by k that consists only of the digit '1'.
子串能表示从 1 到 N 数字的二进制串
Check if binary string contains all integers from 1 to n as substrings, leveraging sliding window and bit manipulation t…
负二进制转换
Convert any non-negative integer into its base -2 representation using a math-driven iterative remainder strategy.
链表中的下一个更大节点
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 maximum absolute difference between a node and its ancestor in a binary tree.
最长等差数列
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…
两个无重叠子数组的最大和
Find the maximum sum of two non-overlapping subarrays by efficiently using state transition dynamic programming.
移动石子直到连续
Solve the "Moving Stones Until Consecutive" problem using math and brainteaser patterns by determining the minimum and m…
边界着色
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 …
从二叉搜索树到更大和树
Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…
多边形三角剖分的最低得分
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…
困于环中的机器人
Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…
不邻接植花
In this problem, you are tasked with planting flowers in gardens with specific constraints based on graph traversal prin…
分隔数组以得到最大和
Partition an array into subarrays of length at most k, replacing each with its maximum to maximize total sum efficiently…
最长字符串链
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…
爱生气的书店老板
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…
按字典序排列最小的等效字符串
Determine the lexicographically smallest string by modeling character equivalences with union find efficiently.
按列翻转得到最大值等行数
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.
活字印刷
Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.
根到叶路径上的不足节点
Remove nodes in a binary tree whose all root-to-leaf paths sum to less than a given limit using DFS traversal and state …
不同字符的最小子序列
The Smallest Subsequence of Distinct Characters problem asks you to find the lexicographically smallest subsequence of a…
受标签影响的最大值
Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.
二进制矩阵中的最短路径
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…
二叉树寻路
The problem involves finding the path from the root to a node in a zigzag-labelled binary tree.
填充书架
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.
有效括号的嵌套深度
This problem challenges you to compute the maximum nesting depth of two valid parentheses strings using stack-based stat…
最深叶节点的最近公共祖先
Find the lowest common ancestor of the deepest leaves in a binary tree using efficient traversal and state tracking tech…
表现良好的最长时间段
The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…
颜色交替的最短路径
Solve the shortest path problem with alternating edge colors using graph traversal and BFS.
叶值的最小代价生成树
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…
字母板上的路径
Find the path to type a target string on an alphabet board using directional moves and the 'hash table plus string' patt…
最大的以 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 …
最长公共子序列
Find the length of the longest common subsequence between two strings using state transition dynamic programming for eff…
递减元素使数组呈锯齿状
Transform any integer array into a zigzag pattern with minimal decrements using a targeted greedy approach and invariant…
二叉树着色游戏
A two-player game where players color nodes in a binary tree, aiming to outmaneuver each other by choosing adjacent node…
快照数组
Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…
掷骰子等于目标和的方法数
Calculate the number of ways to roll n dice with k faces to reach a target sum using state transition dynamic programmin…
单字符重复子串的最大长度
Find the maximum length of a repeated character substring after swapping two characters using a sliding window approach …
最大层内元素和
Find the level of a binary tree where the sum of its nodes is maximal, with an emphasis on binary-tree traversal.
地图分析
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…
从链表中删去总和值为零的连续节点
Remove zero-sum consecutive nodes from a linked list by iterating through it, repeatedly deleting sequences that sum to …
构建回文串检测
Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.
删除一次得到子数组最大和
Find the maximum sum of a subarray with at most one deletion in this dynamic programming problem.
反转每对括号间的子串
Reverse all substrings within matched parentheses using a stack-based approach for efficient state tracking and reversal…
K 次串联后最大子数组之和
Solve the K-Concatenation Maximum Sum problem using dynamic programming and optimal sub-array sum calculation.
丑数 III
Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…
交换字符串中的元素
Find the lexicographically smallest string by swapping characters in given pairs of indices.
尽可能使字符串相等
Optimize substring transformations using a binary search approach to maximize the change within a budget.
删除字符串中的所有相邻重复项 II
Remove all adjacent duplicates in the string using stack-based state management with a given threshold k.
最长定差子序列
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 the probability that the last passenger sits in their assigned seat using state transition dynamic programming…
删除子文件夹
Remove sub-folders in a filesystem by filtering out folders nested inside other folders.
替换子串得到平衡字符串
Determine the minimum substring length to replace in order to balance a string of Q, W, E, and R characters efficiently.
找出给定方程的正整数解
Determine all positive integer pairs that satisfy a hidden monotonic function for a given target using binary search ove…
循环码排列
Generate a circular permutation from a range of numbers using backtracking and bit manipulation.
串联字符串的最大长度
Find the maximum length of a concatenated string from an array with all unique characters using backtracking search with…
交换字符使得字符串相同
This problem requires determining the minimum number of swaps to make two strings equal by swapping characters between t…
统计「优美子数组」
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
移除无效的括号
Given a string with parentheses and letters, remove the fewest parentheses to produce any valid balanced string efficien…
重构 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.
在受污染的二叉树中查找元素
Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…
可被三整除的最大和
Find the maximum sum divisible by three from a given array using dynamic programming and state transition.
统计参与通信的服务器
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 exact counts of jumbo and small burgers using all tomato and cheese slices without leftovers, applying mat…
统计全为 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.
字母组合迭代器
Implement an iterator that generates all combinations of a given length using efficient backtracking with pruning.
删除被覆盖区间
Remove all intervals fully covered by another using sorting and linear traversal, counting only distinct remaining inter…
顺次数
Find all integers within a range whose digits form a strictly increasing consecutive sequence using enumeration techniqu…
元素和小于等于阈值的正方形的最大边长
This problem challenges you to find the largest square in a matrix with a sum below a given threshold using binary searc…
划分数组为连续数字的集合
Determine if an integer array can be partitioned into sets of k consecutive numbers using array scanning and hash mappin…
子串的最大出现次数
Find the maximum number of occurrences of any valid substring in a given string with specific constraints on letter coun…
转变数组后最接近目标值的数组和
Find the integer that mutates all larger elements in an array to minimize the sum difference to a target efficiently.
层数最深叶子节点的和
Find the sum of the deepest leaves in a binary tree by using tree traversal and state tracking techniques.
两棵二叉搜索树中的所有元素
Merge elements from two binary search trees and return them sorted in ascending order.
跳跃游戏 III
Jump Game III challenges you to determine if you can reach any zero in an array using jumps defined by array values, tes…
子数组异或查询
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.
矩阵区域和
Compute a matrix where each cell contains the sum of all elements within k-distance blocks using prefix sums efficiently…
祖父节点值为偶数的节点和
This problem involves calculating the sum of nodes with an even-valued grandparent in a binary tree.
或运算的最小翻转次数
Determine the minimum number of bit flips required in two integers so that their OR equals a target integer efficiently.
连通网络的操作次数
Determine the minimum number of operations required to connect all computers in a network with a limited number of cable…
竖直打印单词
Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…
删除给定值的叶子节点
In this problem, you need to delete all leaf nodes in a binary tree with a given target value, performing continuous del…
破坏回文串
Given a palindrome, change exactly one character to make it non-palindromic and lexicographically smallest using a greed…
将矩阵按对角线排序
Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.
餐厅过滤器
Filter restaurants by vegan-friendly status, price, and distance, and sort them by rating and ID.
阈值距离内邻居最少的城市
Find the city with the fewest neighbors within a given threshold distance using dynamic programming.
数组大小减半
This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…
分裂二叉树的最大乘积
Maximize the product of sums of two subtrees formed by splitting a binary tree.
大小为 K 且平均值大于等于阈值的子数组数目
Given an array, find the number of sub-arrays of size k with an average greater than or equal to a given threshold.
时钟指针的夹角
Calculate the smaller angle between the hour and minute hands of a clock based on given time inputs.
制造字母异位词的最小步骤数
Calculate the minimum steps to transform one string into an anagram of another using character replacements efficiently.
推文计数
Design an efficient solution to track and retrieve tweet counts over different frequencies using binary search and hash …
最后 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.
每隔 n 个顾客打折
Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …
包含所有三种字符的子字符串数目
Count all substrings containing at least one of each character a, b, and c using a sliding window approach efficiently.
验证二叉树
Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.
最接近的因数
Find the closest divisors of num + 1 and num + 2 with minimal absolute difference in this math-driven problem.
通过投票对团队排名
Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…
二叉树中的链表
Determine if a linked list is represented as a downward path in a binary tree using pointer traversal and recursive chec…
每个元音包含偶数次的最长子字符串
Find the longest substring with even counts of vowels using bitmasking and hash tables.
二叉树中的最长交错路径
Find the longest ZigZag path in a binary tree using depth-first search and dynamic programming for precise node state tr…
二进制字符串前缀一致的次数
Count how many times a 1-indexed binary string becomes prefix-aligned as bits are flipped sequentially using an array-dr…
通知所有员工所需的时间
Calculate the time needed for the head of a company to inform all employees using tree traversal techniques.
设计一个支持增量操作的栈
Implement a stack that supports push, pop, and targeted increment operations efficiently using array-based state managem…
将二叉搜索树变平衡
This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.
安排电影院座位
Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…
将整数按权重排序
Sort integers in a range based on their power value using dynamic programming and memoization, handling ties with ascend…
四因数
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.
统计作战单位数
Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…
设计地铁系统
Design an underground system to calculate travel times between stations using hash tables for efficient lookups and aver…
构造 K 个回文字符串
Determine if a string's characters can be rearranged to form exactly k non-empty palindrome strings using greedy validat…
圆和矩形是否有重叠
Determine if a circle intersects with an axis-aligned rectangle using geometric distance checks efficiently in code.
将二进制表示减到 1 的步骤数
Determine the number of steps to reduce a binary representation of a number to 1 by following specific rules.
最长快乐字符串
Solve the "Longest Happy String" problem using a greedy approach with validation of invariants for constructing the long…
查询带键的排列
This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.
HTML 实体解析器
Transform a string containing HTML entities into their character equivalents using a hash table for efficient parsing.
和为 K 的最少斐波那契数字数目
Find the minimum number of Fibonacci numbers that sum up to a given integer k, using a greedy approach.
长度为 n 的开心字符串中字典序第 k 小的字符串
Given n and k, find the k-th lexicographical happy string of length n using backtracking search with pruning.
点菜展示表
Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…
数青蛙
Determine the minimum number of frogs required to sequentially produce all croaks in a mixed frog croak string efficient…
可获得的最大点数
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 …
改变一个整数能得到的最大差值
Compute the maximum difference from changing digits in an integer using greedy choices and invariant checks efficiently.
检查一个字符串是否可以打破另一个字符串
This problem checks whether one string can break another using permutations and a greedy approach for comparison.
绝对差不超过限制的最长连续子数组
Find the longest subarray with elements whose absolute difference is within a specified limit using a sliding window app…
用栈操作构建数组
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…
收集树上所有苹果的最少时间
Minimize the time spent to collect all apples in a tree, considering traversal and state tracking with binary tree techn…
最简分数
Generate simplified fractions between 0 and 1 with denominators up to a given integer n.
统计二叉树中好节点的数目
Count Good Nodes in Binary Tree identifies nodes exceeding all previous values along their path using DFS traversal tech…
重新排列句子中的单词
Rearrange words in a sentence by their length, maintaining original order for words of equal size for consistent output.
收藏清单
Identify people whose favorite companies lists are unique and not subsets of any other person's list using efficient arr…
定长子串中元音的最大数目
Find the maximum number of vowels in a substring of a given length in a string using a sliding window approach.
二叉树中的伪回文路径
Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.
检查一个字符串是否包含所有长度为 K 的二进制子串
Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…
课程表 IV
Determine if one course is a prerequisite of another using graph indegree tracking and topological ordering efficiently.
切割后面积最大的蛋糕
Maximize the area of a piece of cake after specified horizontal and vertical cuts using greedy algorithms and sorting.
重新规划路线
Reorder Routes to Make All Paths Lead to the City Zero involves reversing the direction of roads in a tree to ensure all…
数组中的 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…
子矩形查询
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 …
不同整数的最少数目
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.
n 的第 k 个因子
Find the kth factor of n by scanning divisors carefully or using factor pairs to skip unnecessary checks.
删掉一个元素以后全为 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…
所有蚂蚁掉下来前的最后一刻
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.
仅含 1 的子串数
Calculate the number of contiguous substrings containing only 1s in a binary string using a math and string approach eff…
概率最大的路径
Find the path with the highest success probability in a graph from a start node to an end node, using edge probabilities…
子树中标签相同的节点数
Compute the number of nodes in each subtree sharing the same label using DFS with hash table aggregation efficiently.
和为奇数的子数组数目
Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.
字符串的好分割数目
Count all valid splits of a string where left and right substrings have equal distinct characters, using efficient state…
最少的后缀翻转次数
Find the minimum number of operations to convert a binary string to a target string using bit flips.
好叶子节点对的数量
Find the number of good leaf node pairs in a binary tree where the shortest path between them is less than or equal to a…
找出数组游戏的赢家
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…
K 次操作转变字符串
Determine if string s can be transformed into t within k moves using character shifts and hash table counting efficientl…
平衡括号字符串的最少插入次数
Compute the minimum insertions to transform a parentheses string into a balanced string using efficient stack tracking.
找出第 N 个二进制字符串中的第 K 位
Determine the k-th bit in the n-th binary string using a recursive construction that inverts and reverses previous strin…
和为目标值且不重叠的非空子数组的最大数目
Find the maximum number of non-overlapping subarrays that sum to a given target using efficient scanning and hash lookup…
使数组中所有元素相等的最小操作数
Compute the minimum number of operations to equalize a sequential odd-number array using a precise math-driven approach.
两球之间的磁力
Maximize the minimum magnetic force between balls by strategically placing them in baskets using binary search on positi…
可以到达所有点的最少点数目
Identify the minimum set of vertices in a directed acyclic graph from which all nodes are reachable efficiently using gr…
得到目标数组的最少函数调用次数
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.
你可以获得的最大硬币数目
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…
乘积为正数的最长子数组长度
Given an array, find the maximum length of a subarray with a positive product using dynamic programming.
分割字符串的方案数
Count the number of ways to split a binary string into three non-empty parts with equal numbers of '1's.
删除最短的子数组使剩余数组有序
Find the shortest subarray to remove in order to make an array non-decreasing using binary search and two-pointer techni…
数的平方等于两数乘积的方法数
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.
统计不开心的朋友
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 …
所有排列中的最大和
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…
拆分字符串使唯一子字符串的数目最大
Maximize unique substrings in a string using backtracking with pruning and hash tables to track substrings.
矩阵的最大非负积
Find the maximum non-negative product path in a matrix using dynamic programming and state transition.
经营摩天轮的最大利润
Maximize the profit from operating a Centennial Wheel by determining the optimal number of rotations based on customer a…
王位继承顺序
Throne Inheritance requires modeling a dynamic family tree with births and deaths to determine the kingdom's inheritance…
警告一小时内使用相同员工卡大于等于三次的人
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.
奇偶树
Determine if a binary tree meets Even-Odd rules by checking value parity and strict ordering at each level efficiently.
最大网络秩
Calculate the maximum network rank of two cities by analyzing all city pairs using a graph-driven solution strategy effi…
分割两个字符串得到回文串
Determine if splitting two equal-length strings at a common index can form a palindrome using two-pointer scanning techn…
网络信号最好的坐标
Determine the coordinate with the maximum network quality by summing signal strengths from all reachable towers efficien…
大小为 K 的不重叠线段的数目
Count all valid arrangements of k non-overlapping line segments on n points using state transition dynamic programming.
执行操作后字典序最小的字符串
Optimize a string through rotations and additions to get the lexicographically smallest possible result using string man…
无矛盾的最佳球队
Find the highest score basketball team by choosing players without conflicts in age and score using dynamic programming.
等差子数组
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…
统计只差一个字符的子串数目
Count all substrings from s that differ by exactly one character from some substring in t using precise substring compar…
统计字典序元音字符串的数目
Calculate the number of length-n strings with vowels only that are sorted lexicographically using state transitions.
可以到达的最远建筑
Furthest Building You Can Reach explores a greedy approach with heap-based optimization to find the maximum reachable bu…
字符频次唯一的最小删除次数
Determine the minimum deletions needed to ensure all character frequencies in a string are unique using a greedy approac…
销售价值减少的颜色球
Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.
使字符串平衡的最少删除次数
Determine the minimum number of deletions to transform a string of 'a' and 'b' into a balanced order using DP.
到家的最少跳跃次数
Find the minimum number of jumps needed to reach a target position while avoiding forbidden positions.
确定两个字符串是否接近
Check if two strings can transform into each other using letter swaps and frequency reorganizations, leveraging hash tab…
将 x 减到 0 的最小操作数
Find the minimum number of operations to reduce a value x to zero by removing elements from an array.
具有给定数值的最小字符串
Find the lexicographically smallest string of length n with a given numeric value k using a greedy approach.
生成平衡数组的方案数
Solve Ways to Make a Fair Array by tracking parity sums before and after each removal with prefix-sum style accounting.
合并两个链表
Merge a second linked list into a first by removing a specified range of nodes, testing precise pointer updates and list…
设计前中后队列
Implement a queue that efficiently handles push and pop operations at the front, middle, and back using pointer manipula…
找出最具竞争力的子序列
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.
K 和数对的最大数目
Max Number of K-Sum Pairs is a problem involving counting disjoint pairs with a given sum k in an array.
连接连续二进制数字
Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.
有序数组中差绝对值之和
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 …
十-二进制数的最少数目
This problem asks to find the minimum number of deci-binary numbers needed to sum to a given number represented as a str…
石子游戏 VII
Maximize score difference in a two-player turn-based stone removal game using state transition 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…
平均等待时间
Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…
修改后的最大二进制字符串
The problem asks to maximize a binary string using specific operations to get the highest possible value.
吃苹果的最大数目
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…
大餐计数
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 highest score by greedily removing specific substrings using a stack to track state transitions efficiently.
构建字典序最大的可行序列
Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…
交换链表中的节点
Swap nodes in a linked list using linked-list pointer manipulation and two pointers to solve this medium difficulty prob…
执行交换操作后的最小汉明距离
Solve Minimize Hamming Distance After Swap Operations by grouping swappable indices and matching value counts inside eac…
同积元组
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.
需要教语言的最少人数
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…
满足三条件之一需改变的最少字符数
This problem asks for the minimum operations to change two strings so that one of three conditions is met.
找出第 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.
任意子数组和的绝对值的最大值
Solve for the maximum absolute sum of any subarray using dynamic programming and understanding state transitions.
删除字符串两端相同字符后的最短长度
Minimize string length by deleting similar characters from both ends repeatedly using a two-pointer technique.
移除石子的最大得分
Maximize the score in a solitaire game by optimally removing stones from three piles with a greedy approach.
构造字典序最大的合并字符串
Construct the lexicographically largest merge from two strings using a two-pointer greedy scanning approach efficiently.
统计同质子字符串的数目
This problem requires counting all homogenous substrings in a given string and returning the result modulo 10^9 + 7.
袋子里最少数目的球
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.
移动所有球到每个盒子所需的最小操作数
Solve the problem of finding the minimum operations to move balls to each box using an efficient approach with arrays an…
最接近目标价格的甜点成本
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…
判断一个数字是否可以表示成三的幂的和
Determine if a number can be expressed as the sum of distinct powers of three using a math-driven strategy.
所有子字符串美丽值之和
Calculate the total beauty of all substrings by counting character frequencies and computing frequency differences effic…
构成特定和需要添加的最少元素
Compute the gap between current sum and goal, then greedily cover it with limit-sized additions to get the minimum count…
从第一个节点出发到最后一个节点的受限路径数
Solve the problem of finding the number of restricted paths in a weighted undirected graph, leveraging graph algorithms …
最大平均通过率
Maximize the average pass ratio by assigning extra guaranteed-passing students using a greedy heap strategy for optimal …
设计一个验证系统
Implement an AuthenticationManager using linked-list pointer manipulation and a hash map to track token expirations effi…
你能构造出连续值的最大数目
Find the maximum number of consecutive integer values starting from zero that can be formed using your coins array.
积压订单中的订单总数
Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …
有界数组中指定下标处的最大值
Maximize the value at a given index of an array with constraints using binary search over the valid answer space.
还原排列的最少操作步数
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…
查找用户活跃分钟数
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.
找出游戏的获胜者
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…
统计一个圆中点的数目
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…
最高频元素的频数
Maximize the frequency of an element in an array by incrementing at most `k` elements. Use binary search and greedy tech…
所有元音按顺序排布的最长子字符串
Find the longest substring of all vowels in order within a given string of vowels using sliding window technique.
座位预约管理系统
Manage seat reservations efficiently using a design combining priority queue to always return the lowest available seat …
减小和重新排列数组后的最大元素
Determine the maximum value in an array after decreasing elements and rearranging using a greedy invariant approach.
将字符串拆分为递减的连续值
Check if a string of digits can be split into descending consecutive values where the difference between them is 1.
邻位交换的最小次数
Find the minimum number of adjacent swaps to reach the kth smallest wonderful integer from a given number string.
下标对中的最大距离
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.
增长的内存泄露
Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.
旋转盒子
Rotate a box represented by a character matrix, letting stones fall under gravity using precise two-pointer scanning and…
构成交替字符串需要的最小交换次数
This problem requires finding the minimum number of swaps to make a binary string alternating or determine if it's impos…
找出和为指定值的下标对
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.
跳跃游戏 VII
The problem asks to determine if we can reach the last index of a binary string, with a set range of jumps between indic…
数组中最大数对和的最小值
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.
插入后的最大值
Solve Maximum Value after Insertion by greedily placing x at the first digit that makes the resulting signed number larg…
使用服务器处理任务
Assign tasks to servers efficiently using arrays and heaps, resolving ties by weight and index while tracking availabili…
鸡蛋掉落-两枚鸡蛋
Determine the minimum drops needed to find the critical floor using 2 eggs with optimized state transition dynamic progr…
使数组元素相等的减少操作次数
Find the minimum number of operations to make all array elements equal by reducing the largest elements to the next smal…
使二进制字符串字符交替的最少反转次数
Find the minimum number of flips to make a binary string alternate, using state transition dynamic programming.
找到需要补充粉笔的学生编号
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.
你完成的完整对局数
Solve this math plus string problem to calculate the number of full rounds played in a chess tournament between login an…
统计子岛屿
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…
删除一个字符串中所有出现的给定子字符串
Remove all occurrences of a specified substring from a string using efficient stack-based state management.
最大交替子序列和
Maximize alternating subsequence sum with dynamic programming and state transitions in an array.
循环轮转矩阵
This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …
最美子字符串的数目
Count the number of wonderful non-empty substrings of a given string based on frequency conditions of characters.
消灭怪物的最大数量
Eliminate monsters by strategically using a weapon in a video game to stop them before they reach your city.
统计好数字的数目
Count Good Numbers uses a mathematical pattern with recursion to efficiently count digit strings of length n under stric…
迷宫中离入口最近的出口
Find the shortest path from the maze entrance to the nearest border exit using BFS over a 2D array matrix efficiently.
求和游戏
Determine if Alice can force a win in the Sum Game by strategically replacing '?' using a greedy and invariant approach.
长度为 3 的不同回文子序列
Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.
新增的最少台阶数
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…
最小未被占据椅子的编号
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.
子字符串突变后可能得到的最大整数
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…
你可以工作的最大周数
Maximize the number of weeks you can work on projects with milestone constraints using a greedy approach and invariant v…
收集足够苹果的最小花园周长
Find the minimum perimeter of a square garden that holds enough apples based on a specific formula involving binary sear…
检查操作是否合法
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.
移除石子使总数最小
Minimize the total stones by repeatedly removing half from the largest pile using a greedy heap strategy.
使字符串平衡的最小交换次数
Determine the minimum swaps to balance a bracket string using two-pointer scanning with invariant tracking efficiently.
构造元素不等于两相邻元素平均值的数组
Rearrange an array such that no element equals the average of its neighbors using a greedy approach.
数组元素的最小非零乘积
The problem asks to minimize the product of an array after performing bit-swapping operations on its binary representati…
最大方阵和
Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.
到达目的地的方案数
Find the number of ways to travel from intersection 0 to n - 1 in the shortest time, using a graph-based approach.
找出不同的二进制字符串
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…
找出数组中的第 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.
找到所有的农场组
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.
游戏中弱角色的数量
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.
可互换矩形的组数
Count all pairs of rectangles that share the exact width-to-height ratio using efficient array scanning and hash lookup.
两个回文子序列长度的最大乘积
Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…
从双倍数组中还原原数组
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.
数组美丽值求和
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…
网格游戏
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 …
连接后等于目标字符串的字符串对
Count all unique index pairs in a string array whose concatenation exactly matches the given target string using efficie…
考试的最大困扰度
Maximize the Confusion of an Exam requires adjusting at most k answers to create the longest consecutive true or false s…
找出缺失的观测数据
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…
获取单值网格的最小操作数
Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.
股票价格波动
Design an efficient algorithm for managing stock price fluctuations with incorrect and unordered data in a data stream.
如果相邻两个颜色均相同则删除当前颜色
Alice and Bob play a game removing colored pieces; Alice wins if she makes the last valid move.
网络空闲的时刻
Calculate the time when the network becomes idle, factoring in message resending and the BFS traversal method.
简易银行系统
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 smallest numerically balanced number greater than a given integer using backtracking search and pruning.
统计最高分的节点数目
Find the number of nodes with the highest score in a binary tree, based on subtree sizes and node removal.
两个最好的不重叠活动
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.
找出临界点之间的最小和最大距离
Find the minimum and maximum number of nodes between critical points in a linked list by identifying local minima and ma…
转化数字的最小运算数
Determine the minimum operations needed to convert a number using array elements with addition, subtraction, or XOR oper…
所有子字符串中的元音
Compute the total number of vowels in all substrings of a given string using efficient state transition dynamic programm…
分配给商店的最多商品的最小值
Distribute products to stores so the largest store allocation is minimized using binary search over possible maximums.
模拟行走机器人 II
The Walking Robot Simulation II problem challenges you to simulate robot movements and track its position and direction …
每一个查询的最大美丽值
Determine the maximum beauty of items affordable for each query using efficient binary search and sorting techniques.
反转偶数长度组的节点
Reverse nodes in even length groups while keeping the odd-length groups intact in a given linked list.
解码斜向换位密码
Decode the Slanted Ciphertext problem requires decoding a slanted cipher using string manipulation and simulation based …
给植物浇水
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…
喂食仓鼠的最小食物桶数
Find the minimum number of food buckets required to feed all hamsters, using dynamic programming and greedy techniques.
网格图中机器人回家的最小代价
Find the minimum cost for a robot to return home in a grid with row and column movement costs.
半径为 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.
删除链表的中间节点
Efficiently remove the middle node from a linked list using two-pointer techniques and careful pointer updates to mainta…
从二叉树一个节点到另一个节点每一步的方向
Find the shortest path between two nodes in a binary tree and output the directions as a string of 'L', 'R', and 'U'.
适合野炊的日子
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…
向字符串添加空格
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.
从给定原材料中找到所有可以做出的菜
Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …
判断一个括号字符串是否有效
Determine if a parentheses string can be transformed into a valid sequence considering locked positions using stack logi…
执行所有后缀指令
Simulate robot moves from every instruction index on an n x n grid, counting valid steps without leaving boundaries.
相同元素的间隔之和
Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.
银行中的激光束数量
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 twin sum in a linked list by manipulating pointers efficiently and leveraging stack or reversal techniq…
连接两字母单词得到的最长回文串
Find the maximum-length palindrome by combining two-letter words using array scanning and hash table lookups efficiently…
最少交换次数来组合所有的 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 …
得到目标值的最少行动次数
Calculate the fewest steps to reach a target integer using increments and limited doubles with a greedy strategy.
解决智力问题
Maximize points in an exam with state transition dynamic programming by deciding whether to solve or skip each question.
统计隐藏数组数目
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.
按符号重排数组
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.
分组得分最高的所有下标
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.
设置时间的最少代价
Calculate the minimum fatigue to set a microwave cooking time using digit moves and pushes efficiently.
重排数字的最小值
Rearrange the digits of an integer to minimize its value while avoiding leading zeros, keeping the sign unchanged.
设计位集
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.
找到和为给定整数的三个连续整数
Given a number, find three consecutive integers that sum to it, or return an empty array if no such integers exist.
拆分成最多数目的正偶数之和
Determine the largest set of unique positive even integers that sum to a given finalSum using backtracking and greedy se…
合并零之间的节点
This problem requires merging nodes between zeros in a linked list by summing up the values between consecutive zeros.
构造限制重复的字符串
Construct a lexicographically largest string from a given string with no letter appearing more than a repeatLimit times …
制造字母异位词的最小步骤数 II
Compute the fewest character insertions needed to turn two strings into anagrams using hash table frequency counts effic…
完成旅途的最少时间
Find the minimum time required for buses to complete at least totalTrips using binary search over time multiples.
将杂乱无章的数字排序
Sort numbers based on a custom mapping of their digits, leveraging array manipulation and sorting techniques.
有向无环图中一个节点的所有祖先
Solve the All Ancestors of a Node in a Directed Acyclic Graph problem using graph traversal techniques like BFS, DFS, an…
向数组中追加 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.
统计可以提取的工件
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.
字符串中最多数目的子序列
Maximize the number of subsequences by optimally adding a character to a given string to match a specified pattern.
将数组和减半的最少操作次数
Minimize operations to halve an array's sum using greedy choices and heap data structures.
统计道路上的碰撞次数
Count Collisions on a Road is a problem where you calculate the number of car collisions based on their movements in a s…
射箭比赛中的最大得分
In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…
美化数组的最少删除数
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.
数组的三角和
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
选择建筑的方案数
Solve Number of Ways to Select Buildings by counting alternating 3-building patterns with state transitions over the bin…
找出输掉零场或一场比赛的玩家
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.
向表达式添加括号后的最小结果
Enumerate every valid parenthesis placement around the plus sign and choose the expression with the smallest evaluated p…
K 次增加后的最大乘积
Maximize the product of an array after performing up to k increments using a greedy approach with heap optimization.
买钢笔和铅笔的方案数
Calculate all distinct ways to spend a fixed total on pens and pencils using a straightforward enumeration strategy.
设计一个 ATM 机器
Design an ATM machine that stores and withdraws money with given denominations and prioritizes larger values during with…
完成所有任务需要的最少轮数
The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.
转角路径的乘积中最多能有几个尾随零
Find the maximum trailing zeros in the product of a cornered path within a 2D grid.
统计圆内格点数目
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 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…
必须拿起的最小连续卡牌数
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…
统计值等于子树平均值的节点数
Given a binary tree, count nodes where the value equals the average of values in its subtree.
统计打字方案数
Calculate the total number of possible original texts from a pressed key sequence using state transition dynamic program…
分割数组的方案数
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 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…
最多单词数的发件人
Find the sender with the largest total word count by scanning messages and tallying counts using a hash table efficientl…
道路的最大总重要性
Assign unique values to cities to maximize the total importance of all roads using greedy selection based on city connec…
价格减免
Apply Discount to Prices involves updating a sentence by applying a percentage discount to price words, with precise for…
使数组按非递减顺序排列
Determine the minimum steps to make an array non-decreasing using linked-list pointer manipulation and monotonic stack t…
划分数组使最大差为 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.
网格中的最小路径代价
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…
个位数字为 K 的整数之和
Determine the minimum set of positive integers whose units digits match k and sum exactly to num using DP patterns.
小于等于 K 的最长二进制子序列
Find the longest subsequence in a binary string that forms a number less than or equal to a given integer k.
统计无向图中无法互相到达点对数
Calculate the total number of node pairs in an undirected graph that cannot reach each other using DFS, BFS, or Union Fi…
操作后的最大异或和
Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.
统计放置房子的方式数
This problem asks you to calculate the number of ways to place houses along a street while preventing adjacent houses on…
螺旋矩阵 IV
In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.
知道秘密的人数
Calculate how many people know a secret over n days using state transition dynamic programming and careful simulation of…
坐上公交的最晚时间
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…
无限集中的最小数字
Design a data structure to handle the smallest missing element in an infinite set, with the ability to add and remove el…
移动片段得到字符串
Determine if the pieces in start can be moved to form target using two-pointer scanning and strict left-right movement r…
数位和相等数对的最大和
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…
全 0 子数组的数目
Given an array of integers, count the subarrays that consist entirely of 0s.
设计数字容器系统
Learn to implement a Number Container System using hash tables and design techniques to efficiently track numbers and in…
相等行列对
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.
分组的最大数量
Determine the maximum number of ordered non-empty student groups for a competition using grades array analysis and binar…
找到离给定两个节点最近的节点
Find the node that minimizes the maximum distance to two given nodes in a directed graph with one outgoing edge per node…
统计坏数对的数目
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.
受限条件下可到达节点的数目
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.
最长理想子序列
The Longest Ideal Subsequence problem involves finding the longest subsequence where each character has a difference of …
边积分最高的节点
Determine the node with the highest edge score in a graph using hash table aggregation and careful index tracking.
根据模式串构造最小数字
Construct the lexicographically smallest string that fits the increasing and decreasing conditions of a given pattern.
二进制字符串重新安排顺序需要的时间
Calculate the exact seconds required to convert all 01 pairs into 10 in a binary string using state transitions.
字母移位 II
Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.
最大回文数字
Form the largest palindromic number from a string of digits while maintaining a valid palindrome structure.
感染二叉树需要的总时间
The problem asks to calculate the number of minutes for an infection to spread across all nodes in a binary tree startin…
从字符串中移除星号
Remove all stars from a string by simulating the removal process using a stack to manage characters and stars efficientl…
收集垃圾的最少总时间
This problem asks you to find the minimum amount of time needed to collect all garbage in a city, focusing on array and …
严格回文的数字
Determine if a number is strictly palindromic in all bases from 2 to n minus 2 using two-pointer scanning and invariant …
被列覆盖的最多行数
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
恰好移动 k 步到达某一位置的方法数目
Find the number of ways to reach a position after exactly k steps on an infinite number line using dynamic programming.
最长优雅子数组
Find the length of the longest nice subarray where the bitwise AND of all pairs of elements in the subarray is zero.
子字符串的最优划分
Given a string s, partition it into substrings with unique characters and return the minimum number of substrings.
将区间分为最少组数
Determine the minimum number of non-overlapping groups for a set of intervals using precise two-pointer scanning logic.
运动员和训练师的最大匹配数
Maximize the number of valid player-trainer matchings using two-pointer scanning and careful sorting strategy.
按位或最大的最小子数组长度
Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.
最长的字母序连续子字符串的长度
Find the length of the longest continuous alphabetical substring from a given string of lowercase letters.
反转二叉树的奇数层
Reverse the node values at each odd level in a perfect binary tree, preserving the even levels.
按位与最大的最长子数组
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.
最长上传前缀
Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…
所有数对的异或和
Compute the overall bitwise XOR from all pairings between two arrays using efficient array and bit manipulation techniqu…
沙漏的最大总和
Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…
最小异或
Minimize XOR problem asks for an integer that minimizes XOR with another, applying greedy choices for bit manipulation.
找出前缀异或的原始数组
Find the original array from a given prefix XOR array using bitwise manipulation techniques.
使用机器人打印字典序最小的字符串
Solve the problem of using a robot to print the lexicographically smallest string with stack-based state management.
二的幂数组中查询范围内的乘积
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 …
反转之后不同整数的数目
This problem requires counting distinct integers after performing reverse operations on each integer in an array.
反转之后的数字和
Determine if a non-negative integer can be expressed as the sum of a number and its reverse using enumeration and math r…
最大公因数等于 K 的子数组数目
Count the number of subarrays with GCD equal to a given value k from a list of integers.
距离字典两次编辑以内的单词
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.
最流行的视频创作者
Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…
美丽整数的最小增量
Find the minimum addition to a number such that its digits sum to a value less than or equal to a given target.
长度为 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…
统计构造好字符串的方案数
Count the number of ways to build good binary strings using dynamic programming with state transitions.
树上最大得分和路径
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.
逐层排序二叉树所需的最少操作数目
Determine the minimum number of swaps to sort each level of a binary tree using level-wise traversal efficiently.
二叉搜索树最近节点查询
Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…
到达首都的最少油耗
Calculate the minimum fuel needed for all city representatives to reach the capital using DFS on a tree graph efficientl…
行和列中一和零的差值
This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…
商店的最少代价
Determine the earliest closing hour of a shop to minimize penalty using a string of customer visits and prefix sums.
追加字符以获得子序列
Determine the minimum characters to append to s so t becomes a subsequence using efficient two-pointer scanning techniqu…
从链表中移除节点
This problem requires removing nodes from a linked list when a larger node exists to their right, testing pointer manipu…
划分技能点相等的团队
Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.
两个城市间路径的最小分数
Find the minimum distance in a path connecting two cities using graph traversal strategies efficiently.
图中最大星和
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…
数组中最长的方波
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.
使用质因数之和替换后可以取到的最小值
Replace a number with the sum of its prime factors until it stabilizes, and return the smallest value.
奖励最顶尖的 K 名学生
Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…
最小化两个数组中的最大值
Minimize the Maximum of Two Arrays requires finding the smallest possible maximum number across two arrays, using binary…
每种字符至少取 K 个
Find the minimum number of minutes needed to take at least k of each character from both ends of a string.
礼盒的最大甜蜜度
Maximize the tastiness of a candy basket by choosing k candies from a list of candy prices.
数组乘积中的不同质因数数目
Find the number of distinct prime factors in the product of an array of integers.
将字符串分割成值不超过 K 的子字符串
Determine the minimum number of substrings from a numeric string such that each substring value does not exceed k using …
范围内最接近的两个质数
Find the two closest prime numbers within a given range using efficient number theory techniques and gap comparisons.
找到数据流中的连续整数
Design a data stream checker to identify consecutive integers from a stream, focusing on handling state transitions effi…
查询数组异或美丽值
Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.
执行 K 次操作后的最大分数
Maximize your score by applying exactly k operations on an array using greedy selection and heap optimization techniques…
使字符串中不同字符的数目相等
Determine if a single swap can equalize distinct character counts between two strings using hash tables for tracking fre…
子矩阵元素加 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.
使数组中所有元素相等的最小操作数 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.
执行逐位运算使字符串相等
Determine if a binary string s can be transformed into target using repeated bitwise operations on paired indices effici…
猴子碰撞的方法数
Calculate the total number of monkey collisions on a convex polygon using math and recursion efficiently for large n.
从一个范围内选择最多整数 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…
统计范围内的元音字符串数
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…
统计公平数对的数目
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.
将整数减少到零需要的最少操作数
Compute the minimum number of operations to reduce a positive integer to zero using additions or subtractions of powers …
无平方子集计数
Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…
找出字符串的可整除数组
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…
统计染色格子数
The "Count Total Number of Colored Cells" problem requires deriving a formula to compute colored cells based on elapsed …
统计将重叠区间合并成组的方案数
Count Ways to Group Overlapping Ranges is a medium difficulty problem focused on array manipulation and sorting to count…
二叉树中的第 K 大层和
Find the kth largest level sum in a binary tree using level-order traversal and sorting.
重排数组以得到最大前缀分数
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…
最大化数组的伟大值
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.
找到最大开销的子字符串
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…
等值距离和
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 …
检查是否是类的对象实例
Implement a function to check if an object is an instance of a specific class or its superclass in JavaScript.
有时间限制的缓存
Implement a time-limited cache where keys expire after a given duration, with operations to set, get, and count active k…
记忆函数
This problem focuses on creating a memoized function that caches results to prevent repeated computation with identical …
蜗牛排序
Transform a 1D array into a 2D matrix following the snail traversal core interview pattern efficiently and safely.
扁平化嵌套数组
Flatten Deeply Nested Array involves transforming multi-dimensional arrays based on depth constraints, requiring a caref…
函数防抖
Create a debounced function that delays execution and cancels previous calls within a time window.
分组
Implementing the Group By core interview pattern efficiently sorts array elements into keyed groups based on a selector …
有时间限制的 Promise 对象
Implement a time-limited wrapper for any asynchronous function to enforce execution constraints and prevent overruns.
一个数组所有前缀的分数
Compute the score of each prefix in an array using conversion rules while tracking the maximum efficiently for prefix su…
二叉树的堂兄弟节点 II
Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.
构造有效字符串的最少插入数
Determine the minimum insertions required to transform a given string into repeated concatenations of 'abc' using dynami…
嵌套数组生成器
Implement a generator that performs inorder traversal on a multi-dimensional array of integers.
滑动子数组的美丽值
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…
找到两个数组的前缀公共数组
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.
找出叠涂元素
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.
频率跟踪器
Design a data structure to track values and answer frequency-related queries efficiently using hash tables.
有相同颜色的相邻元素数目
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.
矩阵中的和
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.
相邻值的按位异或
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 number of complete connected components in an undirected graph using efficient traversal techniques and gr…
使用自定义上下文调用函数
Learn to implement a callPolyfill method that correctly sets a function's this context and passes arguments properly.
事件发射器
Design an EventEmitter class that can subscribe, emit, and unsubscribe events, mimicking patterns seen in Node.js or DOM…
求一个整数的惩罚数
Find the punishment number of a given integer using backtracking search with pruning.
精简对象
Compact Object requires removing all falsy values from an object or array recursively to produce a clean, minimal struct…
字符串中的额外字符
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…
对角线上不同值的数量差
Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.
使所有字符相等的最小成本
Find the minimum cost to make all characters of a binary string equal by performing two types of operations.
查询后矩阵的和
Calculate the total sum of a zero-filled n x n matrix after sequentially applying row and column update queries efficien…
并行执行异步函数
Solve the problem of executing asynchronous functions in parallel, handling resolve and reject scenarios effectively.
根据 ID 合并两个数组
Merge two arrays of objects by their id keys, resolving conflicts with arr2 values and sorting by id ascending.
找到最长的半重复子字符串
Find the length of the longest substring where at most one adjacent pair of digits repeats, using a sliding window appro…
移动机器人
Calculate total distances between robots moving on a number line while accounting for collisions using array plus braint…
执行子串操作后的字典序最小字符串
Given a string, perform operations to make it lexicographically smaller using a greedy approach with substring modificat…
收集巧克力
Calculate the minimum cost to collect all chocolate types using rotations and purchases in an array-based enumeration pa…
找出分区值
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.
构造最长的新字符串
Maximize the length of a string built from AA, BB, and AB without creating triple repeats using DP and greedy logic.
字符串连接删减字母
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…
得到整数零需要执行的最少操作数
This problem challenges you to compute the minimum operations to reduce an integer to zero using bit manipulation and st…
将数组划分成若干好子数组的方式
Calculate the number of ways to partition a binary array into good subarrays using state transition dynamic programming …
和等于目标值的质数对
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…
重新放置石块
Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.
将字符串分割为最少的美丽子字符串
Partition a binary string into the fewest beautiful substrings using state transition dynamic programming and careful su…
黑格子的数目
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.
数组的最大美丽值
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.
将字符串中的元音字母排序
Sort Vowels in a String requires identifying vowels in a string and rearranging them in ascending order while keeping co…
访问数组中的位置使分数最大
Maximize your score by visiting positions in an array while handling penalties for parity changes efficiently with DP.
将一个数字表示成幂的和的方案数
Compute the number of ways to express an integer as a sum of unique powers using state transition dynamic programming ef…
合并后数组中的最大元素
This problem focuses on applying greedy choices and merging elements to find the largest element in an array.
统计完全子数组的数目
Count Complete Subarrays in an Array requires scanning the array while tracking elements to detect subarrays with all di…
包含三个字符串的最短字符串
Find the shortest string containing three given strings using a greedy approach while ensuring it is lexicographically s…
在链表中插入最大公约数
The problem involves inserting greatest common divisors between adjacent nodes in a linked list.
使循环数组所有元素相等的最少秒数
Find the minimum number of seconds to equalize a circular array using array scanning and hash lookup techniques.
判断是否能拆分数组
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.
翻倍以链表形式表示的数字
Double a number represented as a linked list by carefully managing node values and carries with pointer traversal techni…
限制条件下元素之间的最小绝对差
Find the minimum absolute difference between two array elements that are at least x indices apart using binary search.
循环增长使字符串子序列等于另一个字符串
Determine if str2 can be made a subsequence of str1 by incrementing characters cyclically using at most one operation.
将三个组排序
Determine the minimum removals to make an array of 1s, 2s, and 3s non-decreasing using dynamic programming transitions.
k-avoiding 数组的最小总和
Determine the minimum sum of a k-avoiding array by choosing distinct integers such that no pair sums to a given k.
销售利润最大化
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…
找出美丽数组的最小和
Find the minimum possible sum of a beautiful array that satisfies the given conditions with the greedy approach.
判断通过操作能否让字符串相等 II
Check if two strings can be made equal using operations that swap characters with the same parity.
几乎唯一子数组的最大和
Find the maximum sum of subarrays that contain at least m distinct elements using array scanning and hash lookups effici…
生成特殊数字的最少操作
Minimize operations to make a number divisible by 25 by deleting digits. Use greedy choice and invariant validation.
统计趣味子数组的数目
Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …
判断能否在给定时间到达单元格
The problem asks if a target cell can be reached from a starting position within a given time on a 2D grid.
将石头分散到网格图的最少移动次数
Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…
删除数对后的最小数组长度
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.
让所有学生保持开心的分组方法数
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…
美丽塔 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…
使数组为空的最少操作次数
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…
有序三元组中的最大值 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.
执行操作使两个字符串相等
Apply Operations to Make Two Strings Equal involves transforming binary strings with a cost-based dynamic programming ap…
最长相邻不相等子序列 II
Find the longest subsequence of indices such that the corresponding strings have a valid Hamming distance and group cons…
最短且字典序最小的美丽子字符串
Find the shortest beautiful substring in a binary string and return the lexicographically smallest option efficiently us…
找出满足差值条件的下标 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.
元素和最小的山形三元组 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.
使二进制字符串变美丽的最少修改次数
This problem involves determining the minimum number of changes to make a binary string beautiful using string-driven st…
和为目标值的最长子序列的长度
Find the length of the longest subsequence in an array that sums to a target value, using dynamic programming.
数组的最小相等和
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 …
找到冠军 II
Identify the strongest team in a tournament DAG using graph-driven logic, ensuring correct handling of in-degree zero ch…
在树上执行操作以后得到的最大分数
Solve Maximum Score After Applying Operations on a Tree by turning healthy-path constraints into subtree DP and forced-v…
给小朋友们分糖果 II
Determine how to distribute n candies among 3 children without exceeding a limit on individual candies.
重新排列后包含指定子字符串的字符串数目
Calculate how many strings of length n can be rearranged to contain "leet" using dynamic programming and combinatorics.
高访问员工
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.
区分黑球与白球
Solve the "Separate Black and White Balls" problem by swapping adjacent balls to group all black balls to the right with…
最大异或乘积
Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.
最大化网格图中正方形空洞的面积
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…
统计美丽子字符串 I
Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.
交换得到字典序最小的数组
Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.
需要添加的硬币的最小数量
Determine the minimum number of coins to add so all values up to target are obtainable using a greedy sum approach.
消除相邻近似相等字符
Minimize operations to remove adjacent almost-equal characters using dynamic programming and greedy methods.
最多 K 个重复元素的最长子数组
Find the maximum length subarray where each number appears at most k times using array scanning and hash lookups.
双模幂运算
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.
划分数组并满足最大差限制
Divide an array into subarrays with a maximum element difference under a given threshold using a greedy approach.
使数组成为等数数组的最小代价
Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…
找到最大周长的多边形
Determine the largest perimeter polygon from a set of side lengths using a greedy approach with invariant validation che…
移除栅栏得到的正方形田地的最大面积
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…
找出出现至少三次的最长特殊子字符串 I
Find the longest special substring in a string that appears at least three times, or return -1 if no such substring exis…
找出出现至少三次的最长特殊子字符串 II
Find the longest special substring that occurs at least three times in a given string using binary search and hash table…
使数组异或和等于 K 的最少操作次数
Find the minimum number of operations to make the XOR of an array equal to a given value k by modifying array elements.
使 X 和 Y 相等的最少操作次数
Determine the minimum operations to make two integers equal using increment, decrement, and division efficiently with DP…
捕获黑皇后需要的最少移动次数
Determine the fewest moves to capture the black queen using only white pieces with careful position analysis.
移除后集合的最多元素数
Maximize a set size by strategically removing half of elements from two arrays using hash lookups and array scanning.
找出数组中的美丽下标 I
Identify all beautiful indices where substring a appears and a nearby substring b exists within distance k efficiently.
价值和小于等于 K 的最大数字
Find the greatest number whose accumulated price, based on binary set bit positions, is less than or equal to k.
判断一个数组是否可以变为有序
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.
按距离统计房屋对数目 I
Determine the number of house pairs at each street distance using graph traversal and breadth-first search efficiently.
输入单词需要的最少按键次数 II
Given a word, find the minimum number of pushes to type it on a remapped keypad using a greedy approach.
子集中元素的最大数量
This problem asks you to find the maximum subset size where each number in the subset follows a specific pattern with ha…
Alice 和 Bob 玩鲜花游戏
Alice and Bob play a turn-based game on a circular field with flowers, where players must choose pairs that satisfy pari…
人员站位的方案数 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…
将单词恢复初始状态所需的最短时间 I
Determine the minimum seconds to revert a string to its original state using repeated prefix shifts of length k efficien…
找出网格的区域平均强度
Find the Grid of Region Average requires identifying regions in a matrix where pixel differences are below a threshold, …
匹配模式数组的子数组数目 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…
进行操作使字符串为空
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…
最长公共前缀的长度
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…
求交集区域内的最大正方形面积
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
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…
元素和小于等于 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.
幸福值最大化的选择方案
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…
执行操作标记数组中的元素
Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…
替换字符串中的问号使分数最小
Minimize the cost of a string with '?' characters by replacing them with letters in lexicographical order while minimizi…
统计以给定字符开头和结尾的子字符串总数
Given a string and a character, find the total number of substrings that start and end with that character.
成为 K 特殊字符串需要删除的最少字符数
Minimize deletions to make a string k-special by adjusting character frequencies.
执行操作使数据元素之和大于等于 K
Given an array nums, find the minimum number of operations to make the sum of elements greater than or equal to k.
最高频率的 ID
Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.
得到更多分数的最少关卡数目
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.
换水问题 II
Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.
交替子数组计数
Count all alternating subarrays in a binary array efficiently using array patterns and simple mathematical reasoning.
满足距离约束且字典序最小的字符串
Minimize a string lexicographically using a series of operations constrained by a given integer k.
使数组中位数等于 K 的最少操作数
The problem involves minimizing operations to make the median of an array equal to a given value k using a greedy approa…
覆盖所有点的最少矩形数目
Find the minimum number of rectangles needed to cover all points, given constraints on width and position.
访问消失节点的最少时间
Determine the minimum time to visit each node in a disappearing-node graph using arrays, graphs, and priority queues eff…
质数的最大距离
Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…
统计特殊字母的数量 II
Count the Number of Special Characters II is a medium difficulty string and hash table problem that involves identifying…
使矩阵满足条件的最少操作次数
This problem asks to find the minimum number of operations on a 2D grid using state transition dynamic programming effic…
直角三角形
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
找出所有稳定的二进制数组 I
Find all stable binary arrays of a given number of 0's, 1's, and limit using dynamic programming and state transitions.
找出与数组相加的整数 II
Given two arrays nums1 and nums2, determine the integer added to nums1 to make it equal to nums2 after removing two elem…
数组最后一个元素的最小值
Construct an array where elements are greater than the previous one, and the bitwise AND of all elements equals a given …
K 周期字符串需要的最少操作次数
The problem requires calculating the minimum number of operations to make a string k-periodic using specific substring r…
同位字符串连接的最小长度
The problem asks to find the minimum length of a string t such that s is a concatenation of anagrams of t.
正方形中的最多点数
Find the maximum number of points inside a valid square centered at the origin using a scanning and hashing approach.
分割字符频率相等的最少子字符串
Partition a string into substrings with equal character frequencies using dynamic programming and state transitions.
从魔法师身上吸取的最大能量
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.
特殊数组 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…
查询数组中元素的出现位置
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…
压缩字符串 III
Compress a string by repeatedly taking maximal same-character prefixes, following a string-driven solution strategy effi…
优质数对的总数 II
Calculate total good pairs by scanning two arrays and using hash lookup to match divisible elements efficiently with k.
无需开会的工作日
Count Days Without Meetings is a problem where you need to count days without scheduled meetings in a given work period.
删除星号以后字典序最小的字符串
Find the lexicographically smallest string by removing stars using stack-based state management and careful character se…
找到连续赢 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.
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
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…
使二进制数组全部等于 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…
包含所有 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…
找出有效子序列的最大长度 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…
与敌人战斗后的最大分数
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.
生成不含相邻零的二进制字符串
Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…
统计 X 和 Y 频数相等的子矩阵数量
Count the number of submatrices with equal frequency of 'X' and 'Y' in a 2D character grid.
从链表中移除在数组中存在的节点
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.
操作后字符串的最短长度
Find the minimum length of a string after performing operations based on character frequency.
使差值相等的最少数组改动次数
Minimize changes to make array differences equal by replacing elements within a given range.
字符串元音游戏
Solve the Vowels Game in a String using optimal moves and string analysis to predict the winner efficiently and accurate…
将 1 移动到末尾的最大操作次数
This problem requires finding the maximum number of operations to move ones to the end of a binary string.
统计不是特殊数字的数字数量
Count the numbers between two integers that are not special, where special numbers are squares of primes.
统计 1 显著的字符串的数量
Count the number of substrings in a binary string with dominant ones, using a sliding window approach with state updates…
最少翻转次数使二进制矩阵回文 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…
新增道路查询后的最短距离 I
Solve shortest paths dynamically in a growing graph using BFS, updating distances efficiently after each road addition q…
统计好节点的数目
Determine how many nodes in a binary tree have all child subtrees of equal size using DFS traversal efficiently.
长度为 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.
超级饮料的最大强化能量
Maximize energy boost from two drinks with a state transition dynamic programming approach.
统计近似相等数对 I
Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.
哈希分割字符串
Hash Divided String requires splitting a string into equal parts and combining character values modulo 26 to form a new …
第 K 近障碍物查询
Solve the K-th nearest obstacle query problem using array and heap (priority queue) techniques to find distances efficie…
范围内整数的最大得分
Maximize Score of Numbers in Ranges asks to find the maximum score by selecting integers within given intervals with a f…
到达数组末尾的最大得分
Calculate the maximum score to reach the end of an array using greedy jumps based on array values and distances.
穿越网格图的安全路径
Determine if you can safely traverse a binary grid from top-left to bottom-right using limited health points.
最高乘法得分
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…
举报垃圾信息
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.
统计重新排列后包含另一个字符串的子字符串数目 I
Count the number of valid substrings in word1 that can be rearranged to contain word2 as a prefix.
高度互不相同的最大塔高和
Assign heights to towers ensuring each height is unique and the total sum is maximized using greedy sorting techniques.
字典序最小的合法序列
Determine the lexicographically smallest valid index sequence by using state transition dynamic programming over word1 a…
元音辅音字符串计数 I
Count all substrings containing every vowel and exactly k consonants using a sliding window and hash map state tracking.
元音辅音字符串计数 II
Count the number of substrings containing all vowels and exactly k consonants using a sliding window technique.
连接二进制表示可形成的最大数值
Determine the largest number achievable by reordering three integers and concatenating their binary forms efficiently.
移除可疑的方法
Remove suspicious methods in a project that are invoked directly or indirectly from a buggy method using graph traversal…
构造最小位运算数组 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…
第 K 大的完美二叉子树的大小
Find the size of the kth largest perfect subtree in a binary tree using tree traversal and state tracking.
出现在屏幕上的字符串序列
Simulate Alice typing a target string with a special keyboard that appends letters one by one. Solve using string simula…
字符至少出现 K 次的子字符串 I
Calculate the total number of substrings where at least one character repeats k times using a sliding window efficiently…
使数组非递减的最少除法操作次数
Determine the minimum number of division operations to make an array non-decreasing using a greedy and invariant-based s…
修改后子树的大小
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…
字符串转换后的长度 I
Calculate the total number of characters in a string after repeated transformations using dynamic programming and freque…
到达最后一个房间的最少时间 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
Find the largest k where two adjacent strictly increasing subarrays of length k exist using binary search techniques.
零数组变换 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…
两个字符串的切换距离
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…
重排子字符串以形成目标字符串
Determine if s can be split into k equal substrings and rearranged to match t using a hash table for frequency tracking.
最小数组和
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.
连接两棵树后最大目标节点数目 I
Maximize the number of target nodes after connecting two trees using binary tree traversal and state tracking.
破解锁的最少时间 I
Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…
使两个整数相等的数位操作
Transform n into m using allowed digit operations without creating primes, applying math and graph strategies efficientl…
用点构造面积最大的矩形 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.
两天自由外汇交易后的最大货币数
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…
统计异或值为给定值的路径数目
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.
执行操作后不同元素的最大数量
Maximize distinct elements in an array by performing at most one operation on each element.
从盒子中找出字典序最大的字符串 I
This problem involves finding the lexicographically largest string from a given word using a two-pointer approach.
统计特殊子序列的数目
Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…
设计任务管理器
Design a Task Manager that can efficiently handle task management operations such as adding, editing, executing, and rem…
最长相邻绝对差递减子序列
Find the length of the longest subsequence with non-increasing absolute adjacent differences.
计算字符串的镜像分数
Calculate the mirror score of a string using stack-based state management for matching letters efficiently and accuratel…
收集连续 K 个袋子可以获得的最多硬币数量
Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…
机器人可以获得的最大金币数
Find the maximum amount of money a robot can collect while neutralizing robbers on its path in a grid.
图的最大边权的最小值
Minimize the maximum edge weight in a graph after removing certain edges while ensuring node reachability.
将数组变相同的最小代价
Minimize cost to make arrays identical by performing operations with given constraints and a greedy strategy.
最多 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…
统计用户被提及情况
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…
重新安排会议得到最多空余时间 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…
K 次修改后的最大曼哈顿距离
Solve Maximum Manhattan Distance After K Changes by scanning prefixes and testing the four diagonal target pairs with li…
按对角线进行矩阵排序
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.
分割正方形 I
Find the minimum y-coordinate of a horizontal line that balances the areas of squares above and below it.
吃披萨
Maximize the total weight gained by optimally eating pizzas in groups of four using greedy selection and invariant valid…
选择 K 个互不重叠的特殊子字符串
Determine if k non-overlapping special substrings exist in a string using dynamic programming and careful substring trac…
提取至多 K 个元素的最大总和
Find the maximum sum by selecting at most k elements from a 2D matrix respecting per-row limits using a greedy strategy.
可行数组的数目
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.
至多 K 次操作后的最长回文子序列
Find the longest palindromic subsequence of a string after performing at most k operations to adjust letters.
长度至少为 M 的 K 个子数组之和
Maximize the sum of k non-overlapping subarrays of at least length m using dynamic programming and prefix sums efficient…
选出和最大的 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…
设计电子表格
Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…
距离最小相等元素查询
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…
操作后最大活跃区段数 I
Maximize the number of active sections in a binary string by performing at most one trade operation.
子字符串连接后的最长回文串 I
Compute the maximum palindrome length by concatenating substrings from two strings using state transition dynamic progra…
设计路由器
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
不同 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…
最小回文排列 I
Build the smallest palindrome by sorting the left half counts and mirroring them around the optional middle character.
执行指令后的得分
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…
找到最常见的回答
Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…
单位转换 I
Solve the unit conversion problem by using graph traversal to compute equivalent unit amounts.
统计水平子串和垂直子串重叠格子的数目
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…
统计被覆盖的建筑
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.
填充特殊网格
Fill a Special Grid uses recursive divide-and-conquer to populate a 2^n x 2^n matrix with sequential integers uniquely i…
将所有元素变为 0 的最少操作次数
Calculate the fewest operations to turn all numbers in an array to zero using subarray minimum elimination strategy.
K 条边路径的最大边权和
Determine the maximum sum of edge weights for a k-edge path in a DAG using state transition dynamic programming efficien…
等和矩阵分割 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…
数位和排序需要的最小交换次数
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.
最大质数子字符串之和
Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.
不相交子字符串的最大数量
Determine the maximum number of non-overlapping substrings in a word, each at least four characters and matching start-e…
给边赋权值的方案数 I
Calculate the number of valid edge weight assignments in a tree using DFS and binary-tree traversal with careful state t…
移除相邻字符
This problem focuses on removing adjacent characters in a string using a stack-based approach until no more operations a…
等积子集的划分方案
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.
选择不同 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…
数组元素相等转换
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.
最小相邻交换至奇偶交替
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…
硬币面值还原
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.
分割字符串
Partition a string into unique segments using hash table and string manipulation.
相邻字符串之间的最长公共前缀
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 involves finding the minimum time to reach the destination in a directed graph with time-dependent edges.
电网维护
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
包含 K 个连通分量需要的最小时间
Find the minimum time to remove edges such that a graph with n nodes has at least k connected components.
用特殊操作处理字符串 I
Simulate a series of operations on a string to transform it into the desired result using special characters.
最小化连通分量的最大成本
Minimize Maximum Component Cost leverages binary search over edge weights to optimize the cost of graph components after…
根据质数下标分割数组
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.
统计梯形的数目 I
Given a list of distinct points, count the number of unique horizontal trapezoids that can be formed by selecting four p…
查找库存不平衡的店铺
Solve Find Stores with Inventory Imbalance by comparing cheapest and most expensive product stock within each store.
中位数之和的最大值
Maximize the sum of medians from subsequences of size 3 by choosing elements wisely from the array.
插入一个字母的最大子序列数
Maximize the number of "LCT" subsequences in a string after one insertion of an uppercase letter.
通过质数传送到达终点的最少跳跃次数
Solve the problem of finding the minimum jumps to reach the end of an array with prime teleportation steps.
使数组平衡的最少移除数目
Determine the fewest elements to remove from nums so the remaining array satisfies the maximum-to-minimum ratio within k…
最早完成陆地和水上游乐设施的时间 II
Determine the minimum completion time for a tourist to ride one land and one water ride using optimal scheduling.
平衡装运的最大数量
The Maximum Balanced Shipments problem requires forming the maximum number of balanced shipments from a given set of par…
变为活跃状态的最小时间
Find the minimum time to activate a string with a given order of replacements and a specific number of valid substrings.
该难度高频题型
Guided Practice Path
AI recommends problems by your level and tracks your progress.
Start Guided Patharrow_forward