题库chevron_right分类chevron_right枚举
label

枚举

118 道题目
简单: 26中等: 58困难: 34

枚举 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
204

计数质数

Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.

中等
479

最大回文数乘积

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

困难
816

模糊坐标

Find all valid 2D coordinate possibilities for an ambiguous input string using backtracking and pruning techniques.

中等
829

连续整数求和

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

困难
845

数组中的最长山脉

Find the length of the longest subarray forming a mountain pattern using state transitions and two-pointer logic efficie…

中等
869

重新排序得到 2 的幂

Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.

中等
906

超级回文数

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

困难
949

给定数字能组成的最大时间

Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.

中等
970

强整数

Find all integers that can be expressed as x^i + y^j up to a given bound using a Hash Table plus Math approach.

中等
1291

顺次数

Find all integers within a range whose digits form a strictly increasing consecutive sequence using enumeration techniqu…

中等
1534

统计好三元组

Count Good Triplets requires identifying all triplets in an array that satisfy multiple absolute difference constraints …

简单
1566

重复至少 K 次且长度为 M 的模式

Determine if a subarray of length m repeats k or more consecutive times in a given integer array efficiently.

简单
1601

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

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

困难
1617

统计子树中城市之间最大距离

This problem asks you to count subtrees in a tree structure where the maximum distance between any two cities matches sp…

困难
1620

网络信号最好的坐标

Determine the coordinate with the maximum network quality by summing signal strengths from all reachable towers efficien…

中等
1625

执行操作后字典序最小的字符串

Optimize a string through rotations and additions to get the lexicographically smallest possible result using string man…

中等
1638

统计只差一个字符的子串数目

Count all substrings from s that differ by exactly one character from some substring in t using precise substring compar…

中等
1761

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

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

困难
1849

将字符串拆分为递减的连续值

Check if a string of digits can be split into descending consecutive values where the difference between them is 1.

中等
1863

找出所有子集的异或总和再求和

Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.

简单
1925

统计平方和三元组的数目

Count Square Sum Triples asks to find the number of integer triples where a² + b² = c² for values between 1 and n.

简单
1952

三除数

Determine if a given integer has exactly three positive divisors.

简单
1958

检查操作是否合法

Determine if a move on an 8x8 board is legal by validating lines in all directions using array and matrix patterns.

中等
1995

统计特殊四元组

Count Special Quadruplets requires scanning arrays and using hash lookups to efficiently find quadruplets matching sum c…

简单
2014

重复 K 次的最长子序列

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

困难
2018

判断单词是否能放入填字游戏内

Determine if a word fits in a crossword grid using array and matrix checks, accounting for spaces, letters, and blocked …

中等
2025

分割数组的最多方案数

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

困难
2044

统计按位或能得到最大值的子集数目

Determine the number of non-empty subsets that achieve the maximum bitwise OR using efficient backtracking and pruning s…

中等
2048

下一个更大的数值平衡数

Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.

中等
2081

k 镜像数字的和

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

困难
2094

找出 3 位偶数

Generate unique 3-digit even numbers from a given array of digits with duplicates.

简单
2122

还原原数组

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

困难
2151

基于陈述统计最多好人数

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

困难
2162

设置时间的最少代价

Calculate the minimum fatigue to set a microwave cooking time using digit moves and pushes efficiently.

中等
2171

拿出最少数目的魔法豆

Determine the minimum beans to remove so all remaining non-empty bags have equal beans using a greedy approach.

中等
2212

射箭比赛中的最大得分

In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…

中等
2232

向表达式添加括号后的最小结果

Enumerate every valid parenthesis placement around the plus sign and choose the expression with the smallest evaluated p…

中等
2234

花园的最大总美丽值

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

困难
2240

买钢笔和铅笔的方案数

Calculate all distinct ways to spend a fixed total on pens and pencils using a straightforward enumeration strategy.

中等
2242

节点序列的最大得分

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

困难
2249

统计圆内格点数目

Count the number of lattice points inside at least one circle in a grid, based on given center and radius data.

中等
2259

移除指定数字得到的最大结果

Determine the largest possible number by removing one specific digit using a greedy approach and string iteration.

简单
2261

含最多 K 个可整除元素的子数组

Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…

中等
2306

公司命名

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

困难
2309

兼具大小写的最好英文字母

Find the greatest English letter that exists in both lowercase and uppercase in a string using a hash table approach.

简单
2310

个位数字为 K 的整数之和

Determine the minimum set of positive integers whose units digits match k and sum exactly to num using DP patterns.

中等
2367

等差三元组的数目

Count the number of arithmetic triplets in a given strictly increasing array with a specified difference.

简单
2397

被列覆盖的最多行数

Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…

中等
2427

公因子的数目

The problem asks to find the number of common factors of two positive integers a and b.

简单
2437

有效时间的数目

Calculate how many valid digital clock times can be formed by replacing unknown digits in a string format hh:mm.

简单
2440

创建价值相同的连通块

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

困难
2443

反转之后的数字和

Determine if a non-negative integer can be expressed as the sum of a number and its reverse using enumeration and math r…

中等
2468

根据限制分割消息

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

困难
2552

统计上升四元组

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

困难
2605

从两个数字数组里生成最小数字

Given two arrays of digits, find the smallest possible number formed by one digit from each array.

简单
2708

一个小组的最大实力值

Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…

中等
2735

收集巧克力

Calculate the minimum cost to collect all chocolate types using rotations and purchases in an array-based enumeration pa…

中等
2749

得到整数零需要执行的最少操作数

This problem challenges you to compute the minimum operations to reduce an integer to zero using bit manipulation and st…

中等
2761

和等于目标值的质数对

Find all prime number pairs that sum up to a given integer n using an efficient sieve-based array approach.

中等
2765

最长交替子数组

Find the longest alternating subarray in a given array of integers.

简单
2768

黑格子的数目

Calculate the number of black blocks in a grid given a list of black cell coordinates.

中等
2778

特殊元素平方和

Calculate the sum of squares of special elements in a 1-indexed array using index divisibility checks efficiently.

简单
2800

包含三个字符串的最短字符串

Find the shortest string containing three given strings using a greedy approach while ensuring it is lexicographically s…

中等
2843

统计对称整数的数目

Count Symmetric Integers finds numbers where the sum of the first half of digits equals the sum of the second half withi…

简单
2844

生成特殊数字的最少操作

Minimize operations to make a number divisible by 25 by deleting digits. Use greedy choice and invariant validation.

中等
2860

让所有学生保持开心的分组方法数

The Happy Students problem asks how many ways a teacher can select a group of students so everyone is happy, based on ce…

中等
2928

给小朋友们分糖果 I

Given two integers n and limit, find the number of ways to distribute n candies among 3 children, with no child receivin…

简单
2929

给小朋友们分糖果 II

Determine how to distribute n candies among 3 children without exceeding a limit on individual candies.

中等
2934

最大化数组末位元素的最少操作次数

Minimize the number of operations needed to maximize the last elements of two arrays with specific swaps.

中等
2947

统计美丽子字符串 I

Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.

中等
2951

找出峰值

Identify all peaks in a mountain array using direct array enumeration and strict neighbor comparisons efficiently.

简单
2959

关闭分部的可行集合数目

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

困难
2970

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

Count the number of incremovable subarrays in an array by removing them to create a strictly increasing sequence.

简单
2975

移除栅栏得到的正方形田地的最大面积

This problem challenges you to calculate the largest square area possible by removing fences from a given rectangular fi…

中等
3001

捕获黑皇后需要的最少移动次数

Determine the fewest moves to capture the black queen using only white pieces with careful position analysis.

中等
3010

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

Divide an array into three contiguous subarrays with minimum cost by leveraging array and sorting principles.

简单
3020

子集中元素的最大数量

This problem asks you to find the maximum subset size where each number in the subset follows a specific pattern with ha…

中等
3025

人员站位的方案数 I

Calculate how many valid pairs of points can be formed on a 2D plane using array and math enumeration techniques efficie…

中等
3027

人员站位的方案数 II

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

困难
3044

出现频率最高的质数

Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…

中等
3091

执行操作使数据元素之和大于等于 K

Given an array nums, find the minimum number of operations to make the sum of elements greater than or equal to k.

中等
3114

替换字符可以得到的最晚时间

Given a time string with "?" characters, replace them to form the latest valid 12-hour time.

简单
3127

构造相同颜色的正方形

Determine if a 3x3 grid can form a 2x2 square of the same color by changing at most one cell efficiently.

简单
3132

找出与数组相加的整数 II

Given two arrays nums1 and nums2, determine the integer added to nums1 to make it equal to nums2 after removing two elem…

中等
3139

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

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

困难
3197

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

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

困难
3200

三角形的最大高度

Find the maximum height of a triangle that can be formed using red and blue balls under given constraints.

简单
3234

统计 1 显著的字符串的数量

Count the number of substrings in a binary string with dominant ones, using a sliding window approach with state updates…

中等
3256

放三个车的价值之和最大 I

Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.

困难
3257

放三个车的价值之和最大 II

Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.

困难
3265

统计近似相等数对 I

Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.

中等
3267

统计近似相等数对 II

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

困难
3272

统计好整数的数目

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

困难
3309

连接二进制表示可形成的最大数值

Determine the largest number achievable by reordering three integers and concatenating their binary forms efficiently.

中等
3345

最小可整除数位乘积 I

Find the smallest number greater than or equal to n whose digit product is divisible by t.

简单
3371

识别数组中的最大异常值

Identify the largest outlier in an integer array using scanning and hash lookup for efficient detection and validation.

中等
3380

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

Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.

中等
3389

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

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

困难
3398

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

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

困难
3403

从盒子中找出字典序最大的字符串 I

This problem involves finding the lexicographically largest string from a given word using a two-pointer approach.

中等
3404

统计特殊子序列的数目

Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…

中等
3411

最长乘积等价子数组

This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …

简单
3434

子数组操作后的最大频率

Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…

中等
3435

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

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

困难
3440

重新安排会议得到最多空余时间 II

Maximize free time by rescheduling at most one meeting using a greedy choice with invariant validation approach for arra…

中等
3445

奇偶频次间的最大差值 II

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

困难
3470

全排列 IV

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

困难
3480

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

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

困难
3483

不同三位偶数的数目

Given an array of digits, find how many distinct 3-digit even numbers can be formed without repetition of digits and no …

简单
3499

操作后最大活跃区段数 I

Maximize the number of active sections in a binary string by performing at most one trade operation.

中等
3503

子字符串连接后的最长回文串 I

Compute the maximum palindrome length by concatenating substrings from two strings using state transition dynamic progra…

中等
3514

不同 XOR 三元组的数目 II

Count all unique XOR results from triplets in an integer array using array traversal and bit manipulation techniques eff…

中等
3546

等和矩阵分割 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…

中等
3548

等和矩阵分割 II

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

困难
3566

等积子集的划分方案

Determine if you can partition an array into two subsets with equal product using recursion and bit manipulation.

中等
3574

最大子数组 GCD 分数

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

困难
3588

找到最大三角形面积

Find the maximum area of a triangle from 2D coordinates with at least one side parallel to the x-axis or y-axis.

中等
3630

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

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

困难

关联高频模式

LeetCode 枚举题型题解:118题训练路线