题库chevron_right分类chevron_right位掩码
label

位掩码

47 道题目
简单: 0中等: 12困难: 35

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

#题目难度
464

我能赢吗

Determine if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…

中等
473

火柴拼正方形

The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…

中等
526

优美的排列

The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…

中等
638

大礼包

Minimize the cost of purchasing items using available special offers with state transition dynamic programming.

中等
691

贴纸拼词

Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…

困难
698

划分为k个相等的子集

Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…

中等
805

数组的均值分割

Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…

困难
847

访问所有节点的最短路径

Solve the Shortest Path Visiting All Nodes problem by exploring dynamic programming, bit manipulation, and breadth-first…

困难
943

最短超级串

This problem requires constructing the shortest string containing all input words using state transition dynamic program…

困难
996

平方数组的数目

Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…

困难
1125

最小的必要团队

Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…

困难
1255

得分最高的单词集合

Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…

困难
1349

参加考试的最大学生数

Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…

困难
1434

每个人戴不同帽子的方案数

Calculate all unique assignments of hats to people using state transition dynamic programming with bitmasking for collis…

困难
1494

并行课程 II

Determine the minimum semesters to complete all courses with prerequisites using state transition dynamic programming an…

困难
1595

连通两组点的最小成本

Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.

困难
1617

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

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

困难
1655

分配重复整数

Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…

困难
1659

最大化网格幸福感

Maximize Grid Happiness is a dynamic programming problem focusing on state transitions with bitmasking to maximize happi…

困难
1681

最小不兼容性

Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.

困难
1723

完成所有工作的最短时间

Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…

困难
1755

最接近目标值的子序列和

Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…

困难
1799

N 次操作后的最大分数和

Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …

困难
1815

得到新鲜甜甜圈的最多组数

Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…

困难
1879

两个数组最小的异或值之和

Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.

困难
1947

最大兼容性评分和

Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…

中等
1986

完成任务的最少工作时间段

Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.

中等
1994

好子集的数目

Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.

困难
2002

两个回文子序列长度的最大乘积

Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…

中等
2035

将数组分成两个数组并最小化数组和的差

Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…

困难
2172

数组的最大与和

Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.

困难
2305

公平分发饼干

The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…

中等
2572

无平方子集计数

Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…

中等
2741

特别的排列

Count the number of special permutations for a given array using dynamic programming and bit manipulation.

中等
2791

树中可以形成回文的路径数

This problem asks you to count all node pairs in a tree whose path characters can be rearranged into a palindrome using …

困难
3003

执行操作后的最大分割数量

Maximizing the number of partitions in a string after changing one character and applying partitioning operations using …

困难
3149

找出分数最低的排列

Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…

困难
3276

选择矩阵中单元格的最大得分

Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.

困难
3283

吃掉所有兵需要的最多移动次数

Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…

困难
3376

破解锁的最少时间 I

Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…

中等
3444

使数组包含目标值倍数的最少增量

This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…

困难
3530

有向无环图中合法拓扑排序的最大利润

Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…

困难
3533

判断连接可整除性

Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …

困难
3539

魔法序列的数组乘积之和

Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…

困难
3575

最大好子树分数

Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…

困难
3594

所有人渡河所需的最短时间

Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.

困难
3615

图中的最长回文路径

Find the longest path in a graph that forms a palindrome using state transition dynamic programming and bitmask techniqu…

困难

关联高频模式

LeetCode 位掩码题型题解:47题训练路线