题库chevron_right分类chevron_right位运算
memory

位运算

220 道题目
简单: 45中等: 97困难: 78

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

#题目难度
29

两数相除

Solve Divide Two Integers by turning repeated subtraction into bit-shifted chunk subtraction with careful sign and overf…

中等
67

二进制求和

Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…

简单
78

子集

Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.

中等
89

格雷编码

Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.

中等
90

子集 II

Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…

中等
136

只出现一次的数字

Solve the Single Number problem using an efficient approach with constant space and linear time complexity.

简单
137

只出现一次的数字 II

Find the single element in an array where every other element appears three times, using bit manipulation and constant s…

中等
187

重复的DNA序列

Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.

中等
190

颠倒二进制位

Reverse a 32-bit unsigned integer by manipulating bits efficiently using a divide and conquer approach with careful bit …

简单
191

位1的个数

Number of 1 Bits is a classic bit manipulation problem where clearing the lowest set bit gives the cleanest count.

简单
201

数字范围按位与

Use shared high bits and bit clearing to solve Bitwise AND of Numbers Range without scanning every value.

中等
222

完全二叉树的节点个数

Count Complete Tree Nodes efficiently by leveraging binary-tree traversal, exploiting completeness, and applying bit man…

简单
231

2 的幂

Determine if a given integer is a power of two using efficient math and bit manipulation techniques with optional recurs…

简单
260

只出现一次的数字 III

Find the two unique numbers in an array where all other numbers appear exactly twice using bit manipulation efficiently.

中等
268

丢失的数字

Find the missing number in an array containing distinct numbers in the range [0, n].

简单
287

寻找重复数

The problem involves finding the duplicate number in an array of integers, using a binary search approach over the valid…

中等
318

最大单词长度乘积

The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…

中等
338

比特位计数

Compute the number of 1 bits for every integer from 0 to n using state transition dynamic programming for efficiency.

简单
342

4的幂

Determine if a given integer is a power of four using math insights and bit manipulation tricks efficiently in code.

简单
371

两整数之和

Solve the Sum of Two Integers problem using bit manipulation and math to avoid using the operators + and -.

中等
389

找不同

Find the Difference involves identifying the additional letter in one string compared to another, emphasizing hash table…

简单
393

UTF-8 编码验证

Determine if an integer array represents valid UTF-8 encoding based on its byte sequences using bit manipulation.

中等
397

整数替换

Find the minimum number of operations to reduce a number to 1 by applying specific operations, using state transition dy…

中等
401

二进制手表

Binary Watch involves generating possible times on a binary watch given a number of turned-on LEDs.

简单
405

数字转换为十六进制数

Convert a 32-bit integer to its hexadecimal string using math operations and careful string manipulation techniques.

简单
421

数组中两个数的最大异或值

Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.

中等
461

汉明距离

Calculate the Hamming distance between two integers by counting differing bit positions.

简单
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…

中等
476

数字的补数

The Number Complement problem requires flipping bits in a number’s binary representation to return its complement.

简单
477

汉明距离总和

Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.

中等
491

非递减子序列

Return all possible non-decreasing subsequences with at least two elements from the input array, nums.

中等
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.

中等
645

错误的集合

Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…

简单
672

灯泡开关 Ⅱ

Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.

中等
691

贴纸拼词

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

困难
693

交替位二进制数

Check whether a given integer has alternating bits using a bit manipulation approach.

简单
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…

中等
756

金字塔转换矩阵

The Pyramid Transition Matrix problem requires determining whether a pyramid can be formed with given blocks and valid p…

中等
762

二进制表示中质数个计算置位

Count numbers with prime set bits in a binary representation within a given range.

简单
779

第K个语法符号

Determine the K-th symbol in a recursively generated grammar table using math and bit manipulation patterns efficiently.

中等
782

变为棋盘

Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.

困难
784

字母大小写全排列

Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.

中等
805

数组的均值分割

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

困难
810

黑板异或游戏

The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…

困难
832

翻转图像

Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.

简单
847

访问所有节点的最短路径

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

困难
861

翻转矩阵后的得分

Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.

中等
864

获取所有钥匙的最短路径

Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.

困难
868

二进制间距

Find the maximum distance between consecutive 1's in a number's binary form using precise bit manipulation techniques.

简单
898

子数组按位或操作

Compute the number of unique bitwise OR values from all non-empty subarrays using dynamic state transitions efficiently.

中等
943

最短超级串

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

困难
957

N 天后的牢房

Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…

中等
980

不同路径 III

Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…

困难
982

按位与为零的三元组

Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…

困难
995

K 连续位的最小翻转次数

Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…

困难
996

平方数组的数目

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

困难
1009

十进制整数的反码

In this problem, you need to return the complement of a given integer by flipping its binary digits.

简单
1016

子串能表示从 1 到 N 数字的二进制串

Check if binary string contains all integers from 1 to n as substrings, leveraging sliding window and bit manipulation t…

中等
1018

可被 5 整除的二进制前缀

Determine which binary prefixes of a given array are divisible by 5 using bit manipulation for efficient checks.

简单
1125

最小的必要团队

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

困难
1177

构建回文串检测

Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.

中等
1178

猜字谜

Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…

困难
1238

循环码排列

Generate a circular permutation from a range of numbers using backtracking and bit manipulation.

中等
1239

串联字符串的最大长度

Find the maximum length of a concatenated string from an array with all unique characters using backtracking search with…

中等
1255

得分最高的单词集合

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

困难
1284

转化为全零矩阵的最少反转次数

Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…

困难
1310

子数组异或查询

Compute XOR results for multiple subarray queries using efficient prefix XOR to reduce repeated computation overhead in …

中等
1318

或运算的最小翻转次数

Determine the minimum number of bit flips required in two integers so that their OR equals a target integer efficiently.

中等
1342

将数字变成 0 的操作次数

Reduce a number to zero using bit manipulation and math. Simulate the process step-by-step based on whether the number i…

简单
1349

参加考试的最大学生数

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

困难
1356

根据数字二进制下 1 的数目排序

Sort an array of integers by the number of 1's in their binary representation and then by their value in case of ties.

简单
1371

每个元音包含偶数次的最长子字符串

Find the longest substring with even counts of vowels using bitmasking and hash tables.

中等
1386

安排电影院座位

Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…

中等
1404

将二进制表示减到 1 的步骤数

Determine the number of steps to reduce a binary representation of a number to 1 by following specific rules.

中等
1434

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

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

困难
1442

形成两个异或相等数组的三元组数目

Efficiently count all triplets in an array where two subarrays formed by splitting have equal XOR using array scanning a…

中等
1457

二叉树中的伪回文路径

Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.

中等
1461

检查一个字符串是否包含所有长度为 K 的二进制子串

Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…

中等
1486

数组异或操作

Compute the bitwise XOR of a dynamically generated array using a combination of math and bit manipulation techniques eff…

简单
1494

并行课程 II

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

困难
1521

找到最接近目标值的函数值

In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.

困难
1525

字符串的好分割数目

Count all valid splits of a string where left and right substrings have equal distinct characters, using efficient state…

中等
1542

找出最长的超赞子字符串

Find the maximum-length awesome substring in a numeric string using hash table and bit manipulation for palindrome poten…

困难
1558

得到目标数组的最少函数调用次数

Calculate the minimum number of modify calls needed to convert an all-zero array into a given target array using greedy …

中等
1595

连通两组点的最小成本

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

困难
1601

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

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

困难
1611

使整数变为 0 的最少操作次数

Compute the minimum number of one-bit operations to convert a given integer to zero using state transition dynamic progr…

困难
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…

困难
1680

连接连续二进制数字

Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.

中等
1681

最小不兼容性

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

困难
1684

统计一致字符串的数目

Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.

简单
1707

与数组中元素的最大异或值

Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…

困难
1720

解码异或后的数组

Recover the original integer array from its XOR-encoded version using direct bitwise manipulation and sequential reconst…

简单
1723

完成所有工作的最短时间

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

困难
1734

解码异或后的排列

Decode XORed Permutation uses prefix reconstruction with global XOR to recover the hidden odd-length permutation in line…

中等
1738

找出第 K 大的异或坐标值

Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…

中等
1755

最接近目标值的子序列和

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

困难
1763

最长的美好子字符串

Find the longest nice substring in a given string using the sliding window technique with running state updates.

简单
1787

使所有区间的异或结果为零

Determine the minimum changes needed in an array so all size-k segments XOR to zero using DP and bit manipulation.

困难
1799

N 次操作后的最大分数和

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

困难
1803

统计异或值在范围内的数对有多少

Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …

困难
1815

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

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

困难
1829

每个查询的最大异或值

Find the maximum XOR for each query based on a sorted array and bit manipulation.

中等
1835

所有数对按位与结果的异或和

Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.

困难
1863

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

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

简单
1879

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

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

困难
1915

最美子字符串的数目

Count the number of wonderful non-empty substrings of a given string based on frequency conditions of characters.

中等
1930

长度为 3 的不同回文子序列

Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.

中等
1938

查询最大基因差

Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.

困难
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…

中等
2032

至少在两个数组中出现的值

Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…

简单
2035

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

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

困难
2044

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

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

中等
2135

统计追加字母可以获得的单词数

Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …

中等
2151

基于陈述统计最多好人数

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

困难
2157

字符串分组

Group words into connected sets using operations on characters with string and bit manipulation techniques.

困难
2172

数组的最大与和

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

困难
2206

将数组划分成相等数对

Determine if an array of 2n integers can be partitioned into n pairs where each pair contains identical elements using h…

简单
2212

射箭比赛中的最大得分

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

中等
2220

转换数字的最少位翻转次数

Determine the minimum number of bit flips required to convert one integer to another using precise bit manipulation.

简单
2275

按位与结果大于零的最长组合

Find the largest group of integers in an array whose bitwise AND is greater than zero using array scanning and hash look…

中等
2305

公平分发饼干

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

中等
2306

公司命名

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

困难
2317

操作后的最大异或和

Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.

中等
2322

从树中删除边的最小分数

Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.

困难
2351

第一个出现两次的字母

Find the first letter that repeats in a string using hash table tracking and early detection for efficiency.

简单
2354

优质数对的数目

Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…

困难
2397

被列覆盖的最多行数

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

中等
2401

最长优雅子数组

Find the length of the longest nice subarray where the bitwise AND of all pairs of elements in the subarray is zero.

中等
2411

按位或最大的最小子数组长度

Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.

中等
2419

按位与最大的最长子数组

Find the length of the longest subarray whose bitwise AND reaches the array's maximum value, combining array scanning wi…

中等
2425

所有数对的异或和

Compute the overall bitwise XOR from all pairings between two arrays using efficient array and bit manipulation techniqu…

中等
2429

最小异或

Minimize XOR problem asks for an integer that minimizes XOR with another, applying greedy choices for bit manipulation.

中等
2433

找出前缀异或的原始数组

Find the original array from a given prefix XOR array using bitwise manipulation techniques.

中等
2438

二的幂数组中查询范围内的乘积

The Range Product Queries of Powers problem requires calculating the product of powers of 2 for a range of queries on a …

中等
2506

统计相似字符串对的数目

Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…

简单
2527

查询数组异或美丽值

Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.

中等
2546

执行逐位运算使字符串相等

Determine if a binary string s can be transformed into target using repeated bitwise operations on paired indices effici…

中等
2564

子字符串异或查询

Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…

中等
2568

最小无法得到的或值

Find the smallest positive integer that cannot be formed from any subsequence OR combination in the array.

中等
2571

将整数减少到零需要的最少操作数

Compute the minimum number of operations to reduce a positive integer to zero using additions or subtractions of powers …

中等
2572

无平方子集计数

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

中等
2588

统计美丽子数组数目

Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…

中等
2595

奇偶位数

Count the number of 1s at even and odd indices in the binary representation of a given integer n.

简单
2657

找到两个数组的前缀公共数组

This problem challenges you to find the prefix common array of two integer permutations, utilizing array scanning and ha…

中等
2680

最大或值

Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.

中等
2683

相邻值的按位异或

Determine if a binary array original exists that produces the given derived array using neighboring bitwise XOR logic.

中等
2708

一个小组的最大实力值

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

中等
2732

找到矩阵中的好子集

Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…

困难
2741

特别的排列

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

中等
2749

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

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

中等
2791

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

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

困难
2835

使子序列的和等于目标的最少操作次数

The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …

困难
2836

在传球游戏中最大化函数值

Maximize the total score in a ball-passing game by selecting the best starting player using state transition dynamic pro…

困难
2857

统计距离为 k 的点对

Solve the problem of counting pairs of points with distance k using array scanning and hash table techniques.

中等
2859

计算 K 置位下标对应元素的和

Sum values in an array where the indices have exactly k set bits in binary representation.

简单
2869

收集元素的最少操作次数

Scan from the end, track seen values from 1 to k, and stop once every required number is collected.

简单
2871

将数组分割成最多数目的子数组

Maximize the number of subarrays in an array while ensuring each subarray's bitwise AND meets the minimum score requirem…

中等
2897

对数组执行操作使平方和最大

Maximizing the sum of squares in an array through bitwise operations on selected elements.

困难
2917

找出数组中的 K-or 值

Given an integer array nums and an integer k, find the K-or of nums where bits qualify based on the occurrence of 1s.

简单
2920

收集所有金币可获得的最大积分

Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.

困难
2932

找出强数对的最大异或值 I

Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.

简单
2935

找出强数对的最大异或值 II

Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.

困难
2939

最大异或乘积

Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.

中等
2959

关闭分部的可行集合数目

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

困难
2980

检查按位或是否存在尾随零

Check if a bitwise OR of two or more numbers has trailing zeros in its binary representation.

简单
2997

使数组异或和等于 K 的最少操作次数

Find the minimum number of operations to make the XOR of an array equal to a given value k by modifying array elements.

中等
3003

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

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

困难
3007

价值和小于等于 K 的最大数字

Find the greatest number whose accumulated price, based on binary set bit positions, is less than or equal to k.

中等
3011

判断一个数组是否可以变为有序

Determine if a given array can be sorted using adjacent swaps restricted by equal set bits in binary representation.

中等
3022

给定操作次数内使剩余元素的或值最小

Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.

困难
3068

最大节点价值之和

Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…

困难
3095

或值至少 K 的最短子数组 I

Find the shortest non-empty subarray in nums whose bitwise OR reaches at least k using sliding window efficiently.

简单
3097

或值至少为 K 的最短子数组 II

Find the length of the shortest subarray where the bitwise OR of all its elements is at least a given value.

中等
3108

带权图里旅途的最小代价

Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…

困难
3116

单面值组合的第 K 小金额

Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…

困难
3117

划分数组得到最小的值之和

Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.

困难
3133

数组最后一个元素的最小值

Construct an array where elements are greater than the previous one, and the bitwise AND of all elements equals a given …

中等
3145

大数组元素的乘积

Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…

困难
3149

找出分数最低的排列

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

困难
3154

到达第 K 级台阶的方案数

Determine the total number of ways to reach the k-th stair using a state transition dynamic programming approach with co…

困难
3158

求出出现两次数字的 XOR 值

Find the XOR of numbers appearing twice by scanning the array and using a hash table for efficient tracking and combinat…

简单
3171

找到按位或最接近 K 的子数组

Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.

困难
3181

执行操作可获得的最大总奖励 II

Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …

困难
3191

使二进制数组全部等于 1 的最少操作次数 I

Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…

中等
3209

子数组按位与值为 K 的数目

The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…

困难
3211

生成不含相邻零的二进制字符串

Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…

中等
3226

使两个整数相等的位更改次数

Find the number of bit changes to make two integers equal using bit manipulation techniques.

简单
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…

困难
3287

求出数组中最大序列值

Determine the maximum value of a subsequence in an integer array using state transition dynamic programming and bit oper…

困难
3304

找出第 K 个字符 I

Find the K-th character in a progressively built string using math and bit manipulation efficiently.

简单
3307

找出第 K 个字符 II

Find the K-th character in a string game using bit manipulation and recursion, optimizing performance for large k values…

困难
3309

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

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

中等
3314

构造最小位运算数组 I

Learn how to construct an array minimizing each element while matching given primes using bitwise operations efficiently…

简单
3315

构造最小位运算数组 II

Learn to build the minimum array matching a bitwise OR pattern for each prime in nums, focusing on binary optimization.

中等
3370

仅含置位位的最小整数

Find the smallest number greater than or equal to n with all set bits in its binary representation.

简单
3376

破解锁的最少时间 I

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

中等
3393

统计异或值为给定值的路径数目

Count the number of paths in a grid where the XOR of all values along the path equals a given number.

中等
3435

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

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

困难
3444

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

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

困难
3495

使数组元素都变为零的最少操作次数

Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…

困难
3513

不同 XOR 三元组的数目 I

Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…

中等
3514

不同 XOR 三元组的数目 II

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

中等
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…

困难
3566

等积子集的划分方案

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

中等
3568

清理教室的最少移动

Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.

中等
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.

困难
3599

划分数组得到最小 XOR

Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…

中等
3615

图中的最长回文路径

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

困难

关联高频模式

LeetCode 位运算题型题解:220题训练路线