面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
无重复字符的最长子串
Find the length of the longest substring without repeating characters using a sliding window and hash map to track state…
整数转罗马数字
Convert a given integer to its Roman numeral representation using hash table mapping and decimal place math operations e…
罗马数字转整数
Convert a Roman numeral string into an integer using a hash table and mathematical principles to determine value order.
电话号码的字母组合
Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…
串联所有单词的子串
Find all starting indices of substrings in a string that are concatenations of a given list of words.
有效的数独
Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …
解数独
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
缺失的第一个正数
Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…
字母异位词分组
Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.
矩阵置零
Modify the matrix in place by setting rows and columns to zero when an element is zero.
最小覆盖子串
Find the smallest substring of s containing all characters from t using a sliding window with running state updates for …
从前序与中序遍历序列构造二叉树
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
Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …
单词接龙
Find the shortest transformation sequence from a start word to an end word, with each word in the sequence differing by …
最长连续序列
Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.
克隆图
Clone Graph involves cloning a graph using DFS, focusing on graph traversal and neighbor management using hash tables.
随机链表的复制
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
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
环形链表
Determine if a given linked list contains a cycle using pointer manipulation or hashing, focusing on detecting repeated …
环形链表 II
Identify the start of a cycle in a linked list using pointer manipulation, efficiently handling edge cases without modif…
LRU 缓存
Implement an efficient LRU Cache using hash table and doubly-linked list to achieve O(1) operations for get and put.
直线上最多的点数
Find the maximum number of points on a straight line in a 2D plane using array scanning and hash lookup.
相交链表
Given two linked lists, find the node where they intersect or return null if they do not.
分数到小数
Convert a fraction into a decimal, handling repeating decimals with parentheses around the repeating part.
多数元素
Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.
重复的DNA序列
Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.
快乐数
Determine if a number is happy by repeatedly summing squares of digits using two-pointer scanning to detect cycles effic…
同构字符串
Determine if two strings are isomorphic by checking if one string can be transformed into the other using character repl…
实现 Trie (前缀树)
This problem requires designing a Trie (Prefix Tree) to efficiently store and query strings using hash table concepts fo…
存在重复元素
Determine if an integer array contains any duplicate values by efficiently scanning with a hash lookup to ensure fast de…
存在重复元素 II
Check if any two equal numbers exist within k indices using array scanning and hash table lookup efficiently.
多数元素 II
Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…
有效的字母异位词
Check if two strings are anagrams using hashing or sorting techniques.
丑数 II
Find the nth ugly number, where ugly numbers have prime factors limited to 2, 3, and 5.
丢失的数字
Find the missing number in an array containing distinct numbers in the range [0, n].
单词规律
Solve Word Pattern by checking a one-to-one mapping between pattern letters and words using hash tables after splitting …
猜数字游戏
Solve the Bulls and Cows problem using hash tables and string manipulation to track exact and misplaced digits.
回文对
Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.
前 K 个高频元素
Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.
两个数组的交集
Find the intersection of two arrays while ensuring unique elements using efficient array scanning and hash lookups.
两个数组的交集 II
Find the intersection of two arrays, accounting for multiple occurrences of the same number.
设计推特
Design Twitter requires implementing post, follow, unfollow, and news feed retrieval using linked-list pointer manipulat…
O(1) 时间插入、删除和获取随机元素
Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.
O(1) 时间插入、删除和获取随机元素 - 允许重复
This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…
赎金信
Determine if a ransom note can be constructed from a magazine's letters using hash tables and string counting techniques…
字符串中的第一个唯一字符
Find the index of the first non-repeating character in a string using efficient queue-driven state processing.
找不同
Find the Difference involves identifying the additional letter in one string compared to another, emphasizing hash table…
完美矩形
Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…
至少有 K 个重复字符的最长子串
Find the length of the longest substring where every character appears at least k times using sliding window and divide-…
随机数索引
Random Pick Index involves selecting a random index of a target number in an array with possible duplicates.
最长回文串
Determine the length of the longest palindrome constructible from a given string using greedy counting and frequency tra…
数组中两个数的最大异或值
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…
全 O(1) 的数据结构
Implement a data structure that tracks string counts and retrieves max or min keys efficiently in constant time.
最小基因变化
Determine the minimum number of single-character gene mutations to reach the target gene using BFS and a hash table look…
找到字符串中所有字母异位词
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.
回旋镖的数量
Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.
找到所有数组中消失的数字
Identify all missing numbers in an array using efficient scanning and hash-based lookup for optimal performance.
根据字符出现频率排序
Sort Characters By Frequency requires counting characters efficiently and rearranging a string in descending frequency o…
四数相加 II
Count all quadruples from four integer arrays that sum to zero using efficient array scanning and hash table lookups.
环形数组是否存在循环
Detect whether a circular array contains a loop of consistent direction using efficient array scanning and hash lookup t…
LFU 缓存
Implement an LFU Cache using linked-list pointer manipulation with constant-time get and put operations for interview sc…
滑动窗口中位数
Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…
非递减子序列
Return all possible non-decreasing subsequences with at least two elements from the input array, nums.
下一个更大元素 I
Find the next greater element for each number in nums1 from the nums2 array using an optimized approach.
键盘行
Identify all words from a list that can be typed using letters from only one row of a standard American keyboard.
出现次数最多的子树元素和
Identify the most frequent subtree sum in a binary tree using DFS and hash table tracking for efficient state management…
随机翻转矩阵
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 maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…
数组中的 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.
砖墙
Solve the Brick Wall problem using array scanning and hash lookups to minimize crossed bricks from a vertical line.
和为 K 的子数组
Count the total number of contiguous subarrays in an integer array that sum exactly to a target value k using optimized …
字符串的排列
Check if a string contains a permutation of another string using two-pointer scanning and hash table techniques.
分糖果
Maximize the number of different candies Alice can eat given a set of candies and constraints on quantity.
最长和谐子序列
Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …
两个列表的最小索引总和
Find the common strings between two lists with the smallest index sum in this easy problem involving array scanning and …
在系统中查找重复文件
Find and return duplicate files in the file system, grouping them by their paths and contents using an array scanning ap…
任务调度器
Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…
最小区间
Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…
错误的集合
Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…
单词替换
Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…
寻找重复的子树
Identify all duplicate subtrees in a binary tree by efficiently tracking structure and values with depth-first traversal…
两数之和 IV - 输入二叉搜索树
Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…
分割数组为连续子序列
Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.
实现一个魔法字典
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.
员工的重要性
Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…
贴纸拼词
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
前K个高频单词
Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…
数组的度
Find the shortest subarray with the same degree as the given array using efficient array scanning and hash lookups.
设计哈希集合
Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…
设计哈希映射
Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…
黑名单中的随机数
Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…
词典中最长的单词
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…
原子的数量
Compute the exact count of each atom in a chemical formula using stack-based state management and hashing techniques eff…
Lisp 语法解析
Parse Lisp expressions using stack-based state management to evaluate variables and operations.
删除并获得点数
Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…
前缀和后缀搜索
Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.
最短补全词
Find the shortest word that completes the license plate by matching all required letters, considering frequency and case…
打开转盘锁
Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.
划分字母区间
Partition a string into maximal parts so that each letter appears in only one segment, using two-pointer scanning.
重构字符串
Reorganize a string so that no two adjacent characters are the same, if possible, using a greedy approach.
基本计算器 IV
Simplify mathematical expressions using stack-based state management, handling variables, operators, and polynomial term…
宝石与石头
Given two strings, determine how many of the stones you have are also jewels, considering case sensitivity.
森林中的兔子
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
自定义字符串排序
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…
唯一摩尔斯密码词
Determine how many unique Morse code transformations can be generated from a list of words using a hash table and array …
子域名访问计数
The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…
公交路线
Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.
链表组件
Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…
最常见的单词
Find the most frequent non-banned word in a paragraph, excluding punctuation, using an efficient array scan and hash tab…
单词的压缩编码
Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…
翻转卡片游戏
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…
统计子串中的唯一字符
Calculate the sum of unique characters in all substrings of a string using state transition dynamic programming.
字符串中的查找与替换
This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …
相似字符串组
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
矩阵中的幻方
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
一手顺子
Check if a hand of cards can be rearranged into groups of consecutive values.
相似度为 K 的字符串
K-Similar Strings involves finding the minimal number of swaps to transform one string into another through character sw…
亲密字符串
Determine if two strings can become equal by swapping exactly two letters using a hash table for character tracking.
二叉树中所有距离为 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.
重新排序得到 2 的幂
Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.
最长的斐波那契子序列的长度
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…
两句话中的不常见单词
Find uncommon words from two sentences by counting word frequencies using hash tables.
公平的糖果交换
Determine which single candy box Alice and Bob should swap to equalize their total candies using array scanning and hash…
根据前序和后序遍历构造二叉树
Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.
查找和替换模式
Identify all words matching a given pattern by checking consistent letter mappings using hash tables and array scanning …
特殊等价字符串组
Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.
最大频率栈
Design a stack-like data structure to manage elements and handle frequent stack operations, including popping the most f…
水果成篮
The Fruit Into Baskets problem requires finding the maximum number of fruits you can pick from a row of trees under spec…
在线选举
Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…
卡牌分组
Solve the problem of determining if a deck can be partitioned into groups with equal occurrences of card values.
单词子集
Word Subsets is solved by merging words2 into one max-frequency requirement, then scanning words1 against that fixed let…
三数之和的多种可能
Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…
尽量减少恶意软件的传播
Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.
尽量减少恶意软件的传播 II
Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.
独特的电子邮件地址
Identify the count of unique email addresses by normalizing local names and using hash-based lookups efficiently.
和相同的二元子数组
Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…
最小面积矩形
Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.
移除最多的同行或同列石头
Maximize the number of stones removed from a 2D plane using graph traversal and DFS.
按公因数计算最大组件大小
Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …
验证外星语词典
Verify if a sequence of words is sorted according to an alien language's custom alphabet order using array scanning and …
二倍数对数组
Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.
N 天后的牢房
Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…
由斜杠划分区域
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
在长度 2N 的数组中找出重复 N 次的元素
Find the element that is repeated exactly N times in a 2N-sized array using array scanning and hash lookups.
最小面积矩形 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…
强整数
Find all integers that can be expressed as x^i + y^j up to a given bound using a Hash Table plus Math approach.
和可被 K 整除的子数组
Count the number of subarrays whose sum is divisible by a given integer k using array scanning and hash lookup.
基于时间的键值存储
Implement a time-based key-value store that retrieves the latest value at a given timestamp using efficient binary searc…
按位与为零的三元组
Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…
二叉树的垂序遍历
Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.
K 个不同整数的子数组
Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.
平方数组的数目
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
找到小镇的法官
Find the Town Judge is an easy LeetCode problem that challenges you to identify a town judge from trust relationships us…
网格照明
Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …
查找共用字符
Return an array of common characters from all strings in the given list of words, including duplicates.
总持续时间可被 60 整除的歌曲
Calculate the number of song pairs whose total durations sum to a multiple of 60 using array scanning and hash lookups.
可被 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…
最长等差数列
Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.
逃离大迷宫
The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…
最长字符串链
Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…
距离相等的条形码
Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…
按列翻转得到最大值等行数
Maximize the number of equal rows in a binary matrix by flipping any number of columns.
元素和为目标值的子矩阵数量
Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…
活字印刷
Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.
受标签影响的最大值
Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.
删点成林
Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.
数组的相对排序
Sort arr1 by the relative order of arr2, with remaining elements placed in ascending order.
最深叶节点的最近公共祖先
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…
等价多米诺骨牌对的数量
Count all pairs of dominoes that are equivalent by scanning the array and using a hash table for fast lookup.
字母板上的路径
Find the path to type a target string on an alphabet board using directional moves and the 'hash table plus string' patt…
快照数组
Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…
单字符重复子串的最大长度
Find the maximum length of a repeated character substring after swapping two characters using a sliding window approach …
拼写单词
Compute the total length of words that can be fully constructed from given characters using array scanning and hash mapp…
查询无效交易
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 …
餐盘栈
Design a system that manages dinner plate stacks using stack-based state management, handling dynamic plate placement an…
构建回文串检测
Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.
猜字谜
Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…
“气球” 的最大数量
Find the maximum number of times the word 'balloon' can be formed from characters of the given string.
交换字符串中的元素
Find the lexicographically smallest string by swapping characters in given pairs of indices.
独一无二的出现次数
Determine if each integer in an array occurs a unique number of times using efficient hash-based counting and verificati…
最长定差子序列
Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.
最大相等频率
Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…
统计「优美子数组」
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
在受污染的二叉树中查找元素
Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…
找出井字棋的获胜者
Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…
用户分组
Organize people into groups based on their specified group sizes using array scanning and hash table bucketing efficient…
转化为全零矩阵的最少反转次数
Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…
划分数组为连续数字的集合
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 videos watched by friends up to a given level and return them sorted by frequency and alphabetically.
数组序号转换
Transform the elements of an array into their ranks, where the rank represents the size order of the elements.
数组大小减半
This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…
跳跃游戏 IV
Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…
检查整数及其两倍数是否存在
Solve Check If N and Its Double Exist by scanning once and checking doubles or halves in a hash set.
制造字母异位词的最小步骤数
Calculate the 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 …
每隔 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.
有多少小于当前数字的数字
In this problem, you need to determine how many numbers are smaller than each element in an array, focusing on array sca…
通过投票对团队排名
Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…
上升下降字符串
Reorder the string based on a specific algorithm using hash tables and string manipulation.
每个元音包含偶数次的最长子字符串
Find the longest substring with even counts of vowels using bitmasking and hash tables.
安排电影院座位
Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…
找出数组中的幸运数
Identify the largest lucky integer in an array by counting frequencies and comparing values with their occurrences effic…
设计地铁系统
Design an underground system to calculate travel times between stations using hash tables for efficient lookups and aver…
统计最大组的数目
Count the number of groups with the largest size by summing digits of numbers from 1 to n using a hash table approach.
构造 K 个回文字符串
Determine if a string's characters can be rearranged to form exactly k non-empty palindrome strings using greedy validat…
HTML 实体解析器
Transform a string containing HTML entities into their character equivalents using a hash table for efficient parsing.
点菜展示表
Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…
旅行终点站
Find the destination city from a list of paths where each path connects two cities. The city with no outgoing path is th…
形成两个异或相等数组的三元组数目
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…
收藏清单
Identify people whose favorite companies lists are unique and not subsets of any other person's list using efficient arr…
通过翻转子数组使两个数组相等
Solve Make Two Arrays Equal by Reversing Subarrays by checking whether target and arr contain the same values with match…
检查一个字符串是否包含所有长度为 K 的二进制子串
Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…
找两个和为目标值且不重叠的子数组
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…
保证文件名唯一
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.
判断路径是否相交
Check if a path crosses itself on a 2D plane using a hash table to track visited points during traversal.
检查数组对是否可以被 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 index pairs in an array where elements match and the first index is smaller, using hash-based scanning efficie…
子树中标签相同的节点数
Compute the number of nodes in each subtree sharing the same label using DFS with hash table aggregation efficiently.
字符串的好分割数目
Count all valid splits of a string where left and right substrings have equal distinct characters, using efficient state…
K 次操作转变字符串
Determine if string s can be transformed into t within k moves using character shifts and hash table counting efficientl…
找出最长的超赞子字符串
Find the maximum-length awesome substring in a numeric string using hash table and bit manipulation for palindrome poten…
和为目标值且不重叠的非空子数组的最大数目
Find the maximum number of non-overlapping subarrays that sum to a given target using efficient scanning and hash lookup…
查找大小为 M 的最新分组
Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…
数的平方等于两数乘积的方法数
Find the number of triplets where the square of a number equals the product of two others, utilizing array scanning and …
使数组和能被 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.
王位继承顺序
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…
两个相同字符之间的最长子字符串
Find the longest substring between two equal characters using a hash table for optimized performance.
等差子数组
Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…
按照频率将数组升序排序
Sort Array by Increasing Frequency requires counting each element and ordering them by frequency, breaking ties with des…
统计只差一个字符的子串数目
Count all substrings from s that differ by exactly one character from some substring in t using precise substring compar…
能否连接形成数组
Determine if an array can be formed by concatenating subarrays without reordering individual elements, using hash lookup…
字符频次唯一的最小删除次数
Determine the minimum deletions needed to ensure all character frequencies in a string are unique using a greedy approac…
设计有序流
Design an Ordered Stream that returns values in increasing order based on unique integer IDs with efficient insertion an…
确定两个字符串是否接近
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 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.
统计一致字符串的数目
Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.
删除子数组的最大得分
Maximize the score by erasing a subarray with unique elements in an array of integers.
大餐计数
Count Good Meals asks you to find pairs of food items with a sum of deliciousness equal to a power of two.
得到子序列的最少操作次数
Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…
同积元组
Given an array of distinct integers, return the number of tuples where the product of two pairs is the same.
需要教语言的最少人数
Minimize the number of users to teach a language that ensures all friends can communicate in a social network.
满足三条件之一需改变的最少字符数
This problem asks for the minimum operations to change two strings so that one of three conditions is met.
盒子中小球的最大数量
The problem asks you to find the box with the maximum number of balls based on the sum of digits of ball numbers.
从相邻元素对还原数组
Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…
唯一元素的和
Given an array, find the sum of all its unique elements by identifying those that appear only once.
最长的美好子字符串
Find the longest nice substring in a given string using the sliding window technique with running state updates.
通过最少操作次数使数组的和相等
Solve the problem of balancing the sums of two integer arrays with minimal operations, using array scanning and hash loo…
所有子字符串美丽值之和
Calculate the total beauty of all substrings by counting character frequencies and computing frequency differences effic…
统计点对的数目
Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.
仅执行一次字符串交换能否使两个字符串相等
Check if one string swap can make two equal strings using hash table and string counting methods.
字符串中第二大的数字
Given a string with alphanumeric characters, find the second largest digit, or return -1 if it doesn’t exist.
设计一个验证系统
Implement an AuthenticationManager using linked-list pointer manipulation and a hash map to track token expirations effi…
字符串中不同整数的数目
Count all unique integers in a string by replacing letters and handling leading zeros correctly with a hash table approa…
替换字符串中的括号内容
Quickly evaluate a string with bracketed keys using array scanning and hash table lookups for efficient replacements.
统计一个数组中好对子的数目
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.
判断句子是否为全字母句
Determine if a given lowercase string contains every English letter using efficient hash table tracking techniques.
有向图中最大颜色值
Compute the maximum color frequency along any valid path in a directed graph using topological ordering and dynamic prog…
找出和为指定值的下标对
Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.
长度为三且各字符不同的子字符串
Count all substrings of length three in a string where each character is unique using sliding window techniques efficien…
检查是否区域内所有整数都被覆盖
Check if all integers in the range [left, right] are covered by intervals in a given set of ranges.
重新分配字符使所有字符串都相等
Determine if you can redistribute characters among strings so that all strings become identical using a counting approac…
查询差绝对值的最小值
Compute minimum absolute differences for subarrays efficiently using array scanning and hash table lookups, leveraging b…
设计电影租借系统
Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.
最美子字符串的数目
Count the number of wonderful non-empty substrings of a given string based on frequency conditions of characters.
长度为 3 的不同回文子序列
Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.
合并多棵二叉搜索树
This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.
可以输入的最大单词数
Determine how many words can be typed on a malfunctioning keyboard with some broken keys.
查询最大基因差
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
检查是否所有字符出现次数相同
Check if a string has characters with equal occurrences using hash tables and string manipulation techniques.
最小未被占据椅子的编号
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.
删除系统中的重复文件夹
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
找出不同的二进制字符串
Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.
树上的操作
Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.
好子集的数目
Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.
统计特殊四元组
Count Special Quadruplets requires scanning arrays and using hash lookups to efficiently find quadruplets matching sum c…
可互换矩形的组数
Count all pairs of rectangles that share the exact width-to-height ratio using efficient array scanning and hash lookup.
差的绝对值为 K 的数对数目
Find how many pairs (i, j) with i < j satisfy |nums[i] - nums[j]| == k using array scanning and hash lookup.
从双倍数组中还原原数组
Given a shuffled array, determine if it is a doubled array and find the original array.
出租车的最大盈利
Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.
使数组连续的最少操作数
Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…
检测正方形
Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…
连接后等于目标字符串的字符串对
Count all unique index pairs in a string array whose concatenation exactly matches the given target string using efficie…
分割数组的最多方案数
Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…
至少在两个数组中出现的值
Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…
股票价格波动
Design an efficient algorithm for managing stock price fluctuations with incorrect and unordered data in a data stream.
简易银行系统
Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…
下一个更大的数值平衡数
Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.
数组中第 K 个独一无二的字符串
Find the kth distinct string in an array by identifying strings that appear only once, using efficient array scanning an…
统计字符串中的元音子字符串
Count the number of vowel substrings that include all five vowels in a string.
检查两个字符串是否几乎相等
Solve Check Whether Two Strings are Almost Equivalent by counting letters and rejecting any character whose frequency ga…
区间内查询数字的频率
Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…
统计出现过一次的公共字符串
Learn how to efficiently count strings appearing exactly once in both arrays using array scanning and hash lookup patter…
找出 3 位偶数
Generate unique 3-digit even numbers from a given array of digits with duplicates.
找到和最大的长度为 K 的子序列
Pick the k largest values, then restore their original order to build the maximum-sum subsequence correctly.
环和杆
Count how many rods have all three colors using a hash table to track colors per rod efficiently in strings.
从给定原材料中找到所有可以做出的菜
Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …
相同元素的间隔之和
Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.
还原原数组
Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…
连接两字母单词得到的最长回文串
Find the maximum-length palindrome by combining two-letter words using array scanning and hash table lookups efficiently…
检查是否每一行每一列都包含全部整数
Determine if every row and column in a square matrix contains all numbers from 1 to n without repetition using array sca…
统计追加字母可以获得的单词数
Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …
找出数组中的所有孤独数字
Find lonely numbers in an array where each lonely number appears once and has no adjacent values.
将找到的值乘以 2
The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …
设计位集
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.
构造限制重复的字符串
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…
数组中紧跟 key 之后出现最频繁的数字
Scan the array once, count which value appears right after the key, and return the uniquely most frequent follower.
根据描述创建二叉树
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.
将数组划分成相等数对
Determine if an array of 2n integers can be partitioned into n pairs where each pair contains identical elements using h…
找出两数组的不同
Find the Difference of Two Arrays helps you identify unique elements between two integer arrays using array scanning and…
找出输掉零场或一场比赛的玩家
Identify players with zero or one losses by efficiently scanning arrays and counting losses using hash lookups for accur…
加密解密字符串
The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …
完成所有任务需要的最少轮数
The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.
多个数组求交集
Find integers that are common across all arrays in a given list of arrays.
统计圆内格点数目
Count the number of lattice points inside at least one circle in a grid, based on given center and radius data.
统计包含每个点的矩形数目
Given a set of rectangles and points, determine how many rectangles contain each point.
花期内花的数目
Find the number of flowers in full bloom at the given times for a list of people.
必须拿起的最小连续卡牌数
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…
字符串的总引力
Calculate the total appeal of all substrings by counting distinct characters efficiently using state transition DP and h…
统计打字方案数
Calculate the total number of possible original texts from a pressed key sequence using state transition dynamic program…
移除字母异位词后的结果数组
This problem requires removing adjacent anagrams from a list of words using an array scanning and hash lookup approach.
按位与结果大于零的最长组合
Find the largest group of integers in an array whose bitwise AND is greater than zero using array scanning and hash look…
判断一个数的数字计数是否等于数位的值
Determine if a number's digits correspond to their counts in the string representation.
最多单词数的发件人
Find the sender with the largest total word count by scanning messages and tallying counts using a hash table efficientl…
重排字符形成目标字符串
Calculate the maximum copies of a target string from letters in s using frequency counting and hash tables efficiently.
替换数组中的元素
Replace Elements in an Array involves applying a series of operations to replace values in an array with new ones based …
替换字符后匹配
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
公司命名
The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…
兼具大小写的最好英文字母
Find the greatest English letter that exists in both lowercase and uppercase in a string using a hash table approach.
解密消息
Decode the Message is an easy problem involving hash table mapping for string decoding based on a cipher key.
无限集中的最小数字
Design a data structure to handle the smallest missing element in an infinite set, with the ability to add and remove el…
数组能形成多少数对
Given an array, count how many pairs can be formed and how many leftovers remain after pairing.
数位和相等数对的最大和
Find the maximum sum of two numbers with equal digit sums in a given array of positive integers.
最好的扑克手牌
Determine the strongest poker hand from five cards using array scanning and hash table counting techniques efficiently.
设计数字容器系统
Learn to implement a Number Container System using hash tables and design techniques to efficiently track numbers and in…
不可能得到的最短骰子序列
Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…
第一个出现两次的字母
Find the first letter that repeats in a string using hash table tracking and early detection for efficiency.
相等行列对
Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…
设计食物评分系统
Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.
优质数对的数目
Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…
使数组中所有元素都等于零
Minimize operations to make all array elements zero by subtracting equal amounts in each operation.
合并相似的物品
Merge Similar Items combines values and weights from two lists, returning the result sorted by value.
统计坏数对的数目
Count the number of bad pairs in an array where the difference between indices and values does not match.
任务调度器 II
Complete tasks in the optimal number of days by considering breaks and task type constraints.
等差三元组的数目
Count the number of arithmetic triplets in a given strictly increasing array with a specified difference.
受限条件下可到达节点的数目
In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…
最长理想子序列
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.
最大回文数字
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…
和相等的子数组
Find Subarrays With Equal Sum is solved by scanning adjacent pairs and storing each length-2 sum in a hash set.
检查相同字母间的距离
Verify if each pair of identical letters in a string has the exact number of letters between them as specified in a dist…
会议室 III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
出现最频繁的偶数元素
Identify the most frequent even element in an array using counting and hash lookup, handling ties by choosing the smalle…
子字符串的最优划分
Given a string s, partition it into substrings with unique characters and return the minimum number of substrings.
按身高排序
Sort the People requires pairing names with heights and sorting them in descending height order efficiently using arrays…
好路径的数目
Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.
删除字符使频率相同
Determine if removing a single letter from a string can make all remaining letters have identical frequency efficiently.
最长上传前缀
Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…
使用机器人打印字典序最小的字符串
Solve the problem of using a robot to print the lexicographically smallest string with stack-based state management.
与对应负数同时存在的最大正整数
Find the largest positive integer in an array such that its negative counterpart also exists.
反转之后不同整数的数目
This problem requires counting distinct integers after performing reverse operations on each integer in an array.
差值数组不同的字符串
Identify the one string in an array whose consecutive letter differences deviate from all others using array scanning pl…
摧毁一系列目标
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…
长度为 K 子数组中的最大和
Find the maximum sum of all distinct-element subarrays of length k using array scanning and hash lookup techniques.
不同的平均值数目
Calculate the number of unique averages formed by repeatedly pairing smallest and largest elements efficiently using has…
数组中不等三元组的数目
Count all triplets in a positive integer array where each element is distinct using scanning and hash lookup efficiently…
统计中位数为 K 的子数组
Count the number of subarrays in a given array with median equal to a specified value k.
划分技能点相等的团队
Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.
让数组不相等的最小总代价
Calculate the minimum cost to rearrange nums1 so that no element matches nums2 using optimal swaps and hash counting.
数组中最长的方波
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.
统计相似字符串对的数目
Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…
添加边使所有节点度数都为偶数
Determine if it's possible to add at most two edges to make all node degrees even in an undirected graph.
奖励最顶尖的 K 名学生
Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…
统计同位异构字符串数目
Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.
每种字符至少取 K 个
Find the minimum number of minutes needed to take at least k of each character from both ends of a string.
数组乘积中的不同质因数数目
Find the number of distinct prime factors in the product of an array of integers.
找到数据流中的连续整数
Design a data stream checker to identify consecutive integers from a stream, focusing on handling state transitions effi…
使字符串中不同字符的数目相等
Determine if a single swap can equalize distinct character counts between two strings using hash tables for tracking fre…
统计好子数组的数目
Count the number of subarrays that contain at least k pairs of equal elements using array scanning and hash lookup.
最小公共值
Find the smallest integer appearing in both sorted arrays efficiently using array scanning and hash-based lookup techniq…
拆分数组的最小代价
Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…
统计桌面上的不同数字
Compute the number of distinct integers generated on a board using repeated modulo operations over a long sequence of da…
从一个范围内选择最多整数 I
Determine the maximum count of integers from 1 to n avoiding banned numbers while keeping the sum under maxSum.
重排水果
Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…
子字符串异或查询
Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…
合并两个二维数组 - 求和法
Merge two 2D arrays by summing values with matching ids using array scanning and hash lookup efficiently.
统计可能的树根数目
Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.
分割数组使乘积互质
Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…
统计美丽子数组数目
Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…
标记所有元素后数组的分数
The problem involves marking elements in an array and calculating the score based on adjacent elements.
美丽子集的数目
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…
从两个数字数组里生成最小数字
Given two arrays of digits, find the smallest possible number formed by one digit from each array.
找到最大开销的子字符串
Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…
转换二维数组
Learn how to convert an integer array into a 2D array with distinct rows using array scanning plus hash lookup efficient…
等值距离和
In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…
二叉树的堂兄弟节点 II
Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.
滑动子数组的美丽值
Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…
找到两个数组的前缀公共数组
This problem challenges you to find the prefix common array of two integer permutations, utilizing array scanning and ha…
找出叠涂元素
Find the first index where a row or column is completely painted in a matrix based on an array of integers.
找出不同元素数目差数组
Calculate the distinct difference array of a given list of integers by counting distinct elements in the prefix and suff…
频率跟踪器
Design a data structure to track values and answer frequency-related queries efficiently using hash tables.
找出转圈游戏输家
Simulate a ball-passing game around a circle using array scanning and hash lookup to find friends who never receive the …
字符串中的额外字符
The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…
对角线上不同值的数量差
Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.
矩阵中严格递增的单元格数
Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…
最小化字符串长度
Minimize String Length asks you to reduce a string by removing duplicates using a Hash Table strategy efficiently.
查询后矩阵的和
Calculate the total sum of a zero-filled n x n matrix after sequentially applying row and column update queries efficien…
判断一个数是否迷人
Determine if a 3-digit number is fascinating by checking if the concatenated result of n, 2*n, and 3*n contains all digi…
找到矩阵中的好子集
Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…
最大字符串配对数目
Find the maximum number of pairs of distinct strings from an array where one string is the reverse of the other.
统计没有收到请求的服务器数目
Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…
美丽下标对的数目
Count all index pairs in an array where the first digit of one number and last digit of another are coprime efficiently.
所有子数组中不平衡数字之和
Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.
重新放置石块
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 minimum index to split an array such that both subarrays have the same dominant element.
最长合法子字符串的长度
This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.
检查数组是否是好的
Determine if a given integer array is a permutation of base[n], containing 1 to n-1 once and n twice, using scanning and…
统计完全子数组的数目
Count Complete Subarrays in an Array requires scanning the array while tracking elements to detect subarrays with all di…
使循环数组所有元素相等的最少秒数
Find the minimum number of seconds to equalize a circular array using array scanning and hash lookup techniques.
子序列最大优雅度
Maximize elegance of a k-length subsequence from a list of items with profits and categories.
数组中的最大数对和
Find the maximum sum of two numbers in an array sharing the same largest digit using a hash-based scan efficiently.
销售利润最大化
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…
判断通过操作能否让字符串相等 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…
统计一个字符串的 k 子序列美丽值最大的数目
Determine the number of k-length unique subsequences in a string that maximize the sum of character frequencies efficien…
统计趣味子数组的数目
Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …
与车相交的点
Count covered integer points by merging overlapping car intervals or marking visited positions on the number line.
删除数对后的最小数组长度
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.
收集元素的最少操作次数
Scan from the end, track seen values from 1 to k, and stop once every required number is collected.
使数组为空的最少操作次数
Minimize the number of operations to make an array empty by leveraging array scanning and hash lookup.
无限数组的最短子数组
Find the shortest subarray in an infinite array that sums to a given target using array scanning and hash lookup.
对数组执行操作使平方和最大
Maximizing the sum of squares in an array through bitwise operations on selected elements.
和带限制的子多重集合的数目
This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.
合法分组的最少组数
The problem involves sorting balls into boxes while minimizing the number of boxes, adhering to size constraints.
子数组不同元素数目的平方和 I
Compute the sum of squares of distinct elements for all subarrays using array scanning with hash lookups efficiently.
找出强数对的最大异或值 I
Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.
高访问员工
Identify employees with high system access within one-hour periods based on access logs.
找出强数对的最大异或值 II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
统计美丽子字符串 I
Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.
统计美丽子字符串 II
Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.
统计完全子字符串
Count Complete Substrings involves finding substrings where each character appears exactly k times with constraints on a…
找到两个数组中的公共元素
Quickly find all numbers that appear in both arrays using scanning and hash lookup to handle duplicates efficiently.
最多 K 个重复元素的最长子数组
Find the maximum length subarray where each number appears at most k times using array scanning and hash lookups.
统计好分割方案的数目
Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…
找出缺失和重复的数字
Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.
移除栅栏得到的正方形田地的最大面积
This problem challenges you to calculate the largest square area possible by removing fences from a given rectangular fi…
找出出现至少三次的最长特殊子字符串 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…
回文串重新排列查询
Given a string and queries, check if rearranging specified substrings can make the string a palindrome.
大于等于顺序前缀和的最小缺失整数
Find the smallest missing integer greater than the sum of the longest sequential prefix in an array.
移除后集合的最多元素数
Maximize a set size by strategically removing half of elements from two arrays using hash lookups and array scanning.
最大频率元素计数
Count Elements With Maximum Frequency is solved by counting each value, tracking the highest count, and summing matching…
将数组分成最小总代价的子数组 II
This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.
输入单词需要的最少按键次数 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…
最大好子数组和
Find the maximum sum of any subarray where the first and last elements differ by exactly k using efficient array scannin…
回文字符串的最大数量
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.
最长公共前缀的长度
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…
分割数组
Determine if an even-length array can be split into two parts with all distinct elements using hash lookup scanning.
在矩阵上写出字母 Y 所需的最少操作次数
Find the minimum number of operations to write the letter Y on a grid by altering cell values.
数组中的最短非公共子字符串
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…
字符串及其反转中是否存在同一子字符串
Check for any substring of length 2 in a string and its reverse using a hash table and string comparison.
成为 K 特殊字符串需要删除的最少字符数
Minimize deletions to make a string k-special by adjusting character frequencies.
每个字符最多出现两次的最长子字符串
Find the maximum length substring where some substring occurs at least twice using a sliding window and hash mapping str…
最高频率的 ID
Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.
统计特殊字母的数量 I
Count the number of special characters in a given string using hash tables and string manipulation.
统计特殊字母的数量 II
Count the Number of Special Characters II is a medium difficulty string and hash table problem that involves identifying…
直角三角形
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
找出唯一性数组的中位数
Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…
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.
两个字符串的排列差
Compute the total index difference between two strings by mapping characters and summing their positional distances effi…
所有数对中数位差之和
Sum of Digit Differences of All Pairs is a problem that involves counting digit differences in pairs from an array of in…
求出出现两次数字的 XOR 值
Find the XOR of numbers appearing twice by scanning the array and using a hash table for efficient tracking and combinat…
查询数组中元素的出现位置
Determine the position of each requested occurrence of x in nums using a hash table and efficient array scanning.
所有球里面不同颜色的数目
Efficiently track colors on balls using array scanning and hash lookup to return the count of distinct colors after each…
优质数对的总数 I
Count all good pairs where an element in nums1 is divisible by a scaled element in nums2 using efficient array scanning.
优质数对的总数 II
Calculate total good pairs by scanning two arrays and using hash lookup to match divisible elements efficiently with k.
删除星号以后字典序最小的字符串
Find the lexicographically smallest string by removing stars using stack-based state management and careful character se…
求出最长好子序列 I
Find the maximum length of a good subsequence by scanning arrays and using hash lookups for value remapping efficiently.
求出最长好子序列 II
Determine the maximum length of a good subsequence in an integer array using array scanning and hash lookup efficiently.
构成整天的下标对数目 I
Count all pairs in an array where their sum forms a complete day using hash-based counting for efficiency.
构成整天的下标对数目 II
Count the number of valid pairs of hours that form a complete day by checking if their sum is a multiple of 24.
施咒的最大总伤害
Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…
从链表中移除在数组中存在的节点
Remove nodes from a linked list if their values exist in a given array.
操作后字符串的最短长度
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.
求出胜利玩家的数目
Find how many players in a game win by picking more balls of a single color than their index position.
设计相邻元素求和服务
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
统计近似相等数对 I
Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.
统计近似相等数对 II
Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.
统计好整数的数目
Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.
数字小镇中的捣蛋鬼
Find the two numbers that appear twice in a list of integers from 0 to n-1 using array scanning plus hash lookup efficie…
举报垃圾信息
Determine if a message contains at least two banned words using array scanning and hash lookup.
统计重新排列后包含另一个字符串的子字符串数目 I
Count the number of valid substrings in word1 that can be rearranged to contain word2 as a prefix.
统计重新排列后包含另一个字符串的子字符串数目 II
Count Substrings That Can Be Rearranged to Contain a String II involves identifying valid substrings with a sliding wind…
元音辅音字符串计数 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.
构造符合图结构的二维矩阵
This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.
查询排序后的最大公约数
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
从原字符串里进行删除操作的最多次数
Determine the maximum number of characters you can remove from source while keeping pattern as a subsequence using array…
计算子数组的 x-sum I
Compute the x-sum of every subarray of length k efficiently using array scanning combined with hash lookup techniques.
计算子数组的 x-sum II
Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.
字符至少出现 K 次的子字符串 I
Calculate the total number of substrings where at least one character repeats k times using a sliding window efficiently…
判断 DFS 字符串是否是回文串
Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…
修改后子树的大小
Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…
字符串转换后的长度 I
Calculate the total number of characters in a string after repeated transformations using dynamic programming and freque…
字符串转换后的长度 II
Calculate the length of a string after repeated transformations using state transition dynamic programming for large t v…
好子序列的元素之和
Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.
重排子字符串以形成目标字符串
Determine if s can be split into k equal substrings and rearranged to match t using a hash table for frequency tracking.
识别数组中的最大异常值
Identify the largest outlier in an integer array using scanning and hash lookup for efficient detection and validation.
使数组的值全部为 K 的最少操作次数
Find the minimum operations to convert an array to all values equal k using array scanning and hash lookup efficiently.
统计最小公倍数图中的连通块数目
Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…
长度可被 K 整除的子数组的最大元素和
Find the maximum sum of a subarray where the length of the subarray is divisible by k.
使字符频率相等的最少操作次数
This Hard problem asks to transform a string so all character frequencies match using minimal deletions, leveraging dyna…
唯一中间众数子序列 I
Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.
使数组元素互不相同所需的最少操作次数
Find the minimum number of operations to make all elements of an array distinct.
统计特殊子序列的数目
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…
计算字符串的镜像分数
Calculate the mirror score of a string using stack-based state management for matching letters efficiently and accuratel…
最长特殊路径
Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.
子数组操作后的最大频率
Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…
找到字符串中合法的相邻数字
Identify the first valid adjacent digit pair in a string where each digit appears exactly as many times as its numeric v…
奇偶频次间的最大差值 I
Find the maximum difference between the frequency of characters in a string with odd and even frequencies.
K 次修改后的最大曼哈顿距离
Solve Maximum Manhattan Distance After K Changes by scanning prefixes and testing the four diagonal target pairs with li…
将元素分配给有约束条件的组
Assign elements to groups by size constraints with a sieve-like approach to find suitable element matches efficiently.
选择 K 个互不重叠的特殊子字符串
Determine if k non-overlapping special substrings exist in a string using dynamic programming and careful substring trac…
找出最大的几近缺失整数
Find the largest almost missing integer in an array where it appears in exactly one subarray of size k.
不同三位偶数的数目
Given an array of digits, find how many distinct 3-digit even numbers can be formed without repetition of digits and no …
设计电子表格
Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…
最长特殊路径 II
Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…
删除后的最大子数组元素和
Maximize the sum of a subarray after performing deletions, ensuring elements remain unique.
距离最小相等元素查询
Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.
属性图
Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…
使 K 个子数组内元素相等的最少操作数
Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…
移除最小数对使数组有序 I
This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.
设计路由器
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
最大化交错和为 K 的子序列乘积
Find the maximum product of a subsequence in an array with an alternating sum equal to a given target.
移除最小数对使数组有序 II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
最小回文排列 II
Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.
执行指令后的得分
Simulate a series of add and jump instructions on arrays to compute the final score efficiently using array scanning and…
找到最常见的回答
Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…
统计被覆盖的建筑
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.
找到频率最高的元音和辅音
Given a string, calculate the sum of the most frequent vowel and consonant frequencies.
将所有元素变为 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…
不同字符数量最多为 K 时的最少删除数
You need to delete characters in a string to reduce its distinct characters to at most k.
等和矩阵分割 II
Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.
数位和排序需要的最小交换次数
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…
清理教室的最少移动
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…
统计特殊三元组
Count Special Triplets requires scanning an array while tracking counts of previous and next values efficiently with has…
找到最大三角形面积
Find the maximum area of a triangle from 2D coordinates with at least one side parallel to the x-axis or y-axis.
检查元素频次是否为质数
Check if any element in the array has a prime frequency count, leveraging array scanning and hash table lookup.
分割字符串
Partition a string into unique segments using hash table and string manipulation.
优惠券校验器
The Coupon Code Validator problem requires filtering and sorting coupons based on specific criteria for validity.
电网维护
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
统计梯形的数目 I
Given a list of distinct points, count the number of unique horizontal trapezoids that can be formed by selecting four p…
统计梯形的数目 II
Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…