Bit Manipulation
Advanced & DPO(1) low-level bitwise operations, masks, and XOR parity tricks
226 problems·45 Easy·107 Medium·74 Hard
Pattern Study Guide & Cheat Sheet▼
Perform bitwise operations (&, |, ^, ~, <<, >>) to check, set, toggle, or count bits in O(1) time and space without allocating memory.
Core Invariant: Essential Bit Identities: 1) `x ^ x = 0` and `x ^ 0 = x` (cancels pairs); 2) `n & (n - 1)` clears the lowest set bit (Brian Kernighan); 3) `n & -n` isolates lowest set bit; 4) `(1 << k)` creates mask for k-th bit.
Recognize it (Keywords & Signals)
- Single number (every element appears twice except one)
- Number of 1 bits (Hamming weight)
- Counting bits from 0 to N
- Subsets represented as bitmasks (N <= 20)
- Power of two verification
When NOT to use
Numbers exceed 64-bit integer limits and bitwise representations become complex strings, or problem requires decimal digits.
How to solve (Step-by-step)
- 1.Identify if problem involves duplicate cancellation (XOR), bit counting (`n & (n - 1)`), or subset mask (`1 << n`).
- 2.To clear lowest set bit: `n &= (n - 1)` in a loop until `n == 0`.
- 3.To check if k-th bit is set: `(n & (1 << k)) != 0`.
- 4.To toggle k-th bit: `n ^= (1 << k)`.
- 5.To check power of two: `n > 0 and (n & (n - 1)) == 0`.
Watch for (Interview Traps)
- Operator precedence: `==` has higher precedence than `&` in Python! Always wrap `(n & (1 << i)) != 0` in parentheses
- Negative numbers in Python: Python uses arbitrary-precision integers, so bit shifts on negative numbers require masking with `0xFFFFFFFF`
- Off-by-one in bit shifts: 0-indexed vs 1-indexed bit positions
Brian Kernighan's Bit Counting & XOR Reduction
def single_number(nums: list[int]) -> int:
# XOR Property: x ^ x = 0 and x ^ 0 = x
# All duplicate pairs cancel out, leaving the unique single number
unique = 0
for x in nums:
unique ^= x
return unique
def count_set_bits(n: int) -> int:
# Brian Kernighan's Algorithm: n & (n - 1) clears the lowest set bit
count = 0
while n > 0:
n &= (n - 1)
count += 1
return count- Cost
- O(1) or O(number of set bits) · O(1) strictly constant memory (Hardware-level instructions with blazing fast execution.)
Canonical problems
#136 Single Number: XOR all numbers to cancel duplicates in O(N) time and O(1) space
#191 Number of 1 Bits: Clear lowest bit with n & (n - 1) in loop
#231 Power of Two: n > 0 and (n & (n - 1)) == 0
#338 Counting Bits: DP on bits: dp[i] = dp[i >> 1] + (i & 1)
⌘K
Medium·24 companies·Max freq 90%·Acc 64.6%
NianticNeetCode 150NeetCode 150+21
Hard·9 companies·Max freq 100%·Acc 23.9%
ArcesiumSamsungTexas Instruments+6
Medium·8 companies·Max freq 100%·Acc 62.8%
Salesforce6senseNvidia+5
Medium·8 companies·Max freq 88%·Acc 63.7%
GeicoToptalGeneral Motors+5
Medium·8 companies·Max freq 75%·Acc 38.8%
LinkedInZeta GlobalAmazon+5
Easy·7 companies·Max freq 100%·Acc 88.0%
persistent systemsIBMMeta+4
Easy·7 companies·Max freq 100%·Acc 85.9%
Hudson River TradingHudson River TradingGoogle+4
Medium·7 companies·Max freq 100%·Acc 45.8%
GuidewireAmerican ExpressGeico+4
Medium·7 companies·Max freq 64%·Acc 89.5%
BNY MellonCitadelGoogle+4
Medium·6 companies·Max freq 100%·Acc 54.8%
PayPal HoneyGrowwPalo Alto Networks+3
Medium·6 companies·Max freq 100%·Acc 66.4%
Edelweiss GroupEdelweiss GroupMeta+3
Medium·6 companies·Max freq 100%·Acc 65.4%
fourkitesBloombergMeta+3
Hard·6 companies·Max freq 100%·Acc 0.5%
thoughtspotWeRideUber+3
Hard·6 companies·Max freq 75%·Acc 68.2%
DE ShawTuringGoogle+3
Medium·6 companies·Max freq 66%·Acc 88.3%
YandexGoogleMeta+3
Medium·6 companies·Max freq 50%·Acc 80.4%
UberMicrosoftGoogle+3
Medium·6 companies·Max freq 39%·Acc 73.8%
VisaGoogleAmazon+3
Medium·6 companies·Max freq 38%·Acc 75.6%
MicrosoftGoldman SachsBloomberg+3
Medium·5 companies·Max freq 100%·Acc 0.6%
MeeshoGoogleMicrosoft+2
Easy·5 companies·Max freq 100%·Acc 85.3%
AonAmazonBloomberg+2
Medium·5 companies·Max freq 97%·Acc 0.8%
Hudson River TradingJump TradingAdobe+2
#2939Maximum Xor Product
Medium·5 companies·Max freq 94%·Acc 30.2%
Squarepoint CapitalZomatoRippling+2
Hard·5 companies·Max freq 91%·Acc 78.3%
ExpediaOracleServiceNow+2
Medium·5 companies·Max freq 68%·Acc 61.2%
TrilogyGoldman SachsGoogle+2
Medium·5 companies·Max freq 59%·Acc 0.9%
PaytmAmazonBloomberg+2
Medium·5 companies·Max freq 55%·Acc 61.6%
GrammarlyGoogleAmazon+2
Hard·5 companies·Max freq 53%·Acc 46.0%
PinterestAmazonMicrosoft+2
Medium·5 companies·Max freq 38%·Acc 53.6%
GoogleBloombergAmazon+2
Easy·5 companies·Max freq 25%·Acc 81.5%
MetaAmazonBloomberg+2
Medium·5 companies·Max freq 25%·Acc 61.9%
AmazonBloombergGoogle+2
Hard·4 companies·Max freq 100%·Acc 69.4%
Deutsche BankBlackRockMeta+1
Medium·4 companies·Max freq 100%·Acc 50.2%
MitsogoMetaMicrosoft+1
Hard·4 companies·Max freq 100%·Acc 60.3%
Axis BankBloombergGoogle+1
Medium·4 companies·Max freq 100%·Acc 66.6%
AonMicrosoftAmazon+1
Easy·4 companies·Max freq 100%·Acc 82.4%
MapboxMicrosoftGoogle+1
Medium·4 companies·Max freq 88%·Acc 88.4%
Morgan StanleyNvidiaMicrosoft+1
Hard·4 companies·Max freq 25%·Acc 76.1%
AmazonMetaMicrosoft+1
Medium·4 companies·Max freq 18%·Acc 58.2%
BloombergAmazonGoogle+1
Hard·3 companies·Max freq 100%·Acc 46.4%
MindtickleRobloxDE Shaw
Easy·3 companies·Max freq 100%·Acc 88.5%
RobinhoodBloombergGoogle
Hard·3 companies·Max freq 100%·Acc 52.6%
TuSimpleOracleMicrosoft
Medium·3 companies·Max freq 31%·Acc 0.6%
InfosysBloombergGoogle
Hard·3 companies·Max freq 25%·Acc 81.5%
AmazonBloombergGoogle
Medium·3 companies·Max freq 25%·Acc 66.7%
AmazonBloombergGoogle
Hard·3 companies·Max freq 13%·Acc 48.4%
BloombergAmazonGoogle
Hard·3 companies·Max freq 13%·Acc 72.5%
BloombergAmazonGoogle
Medium·2 companies·Max freq 69%·Acc 49.5%
MicrostrategyGoogle
Medium·2 companies·Max freq 63%·Acc 35.1%
SwiggyAmazon
Hard·2 companies·Max freq 38%·Acc 61.7%
InfosysMeta
Medium·2 companies·Max freq 38%·Acc 72.0%
MicrosoftGoogle
Easy·2 companies·Max freq 25%·Acc 78.9%
AmazonGoogle
Medium·2 companies·Max freq 13%·Acc 84.8%
MetaGoogle
Medium·2 companies·Max freq 13%·Acc 65.6%
AmazonGoogle
Hard·1 companies·Max freq 100%·Acc 47.4%
American Express
Hard·1 companies·Max freq 100%·Acc 53.4%
HiLabs
Easy·1 companies·Max freq 100%·Acc 63.6%
ThoughtWorks
Hard·1 companies·Max freq 90%·Acc 47.0%
Sprinklr
Medium·1 companies·Max freq 90%·Acc 42.8%
Sprinklr
Hard·1 companies·Max freq 90%·Acc 44.9%
Sprinklr
Medium·1 companies·Max freq 88%·Acc 72.8%
Walmart Labs
Hard·1 companies·Max freq 75%·Acc 36.9%
DE Shaw
Hard·1 companies·Max freq 75%·Acc 72.9%
Airbnb
Medium·1 companies·Max freq 25%·Acc 62.8%
Amazon
# | Problem | Difficulty | Top Companies↓ | Frequency | Acceptance | |
|---|---|---|---|---|---|---|
| #287 | Find the Duplicate Number ArrayTwo PointersBinary SearchBit ManipulationPigeonhole PrincipleFloyd's Cycle Finding Algorithm | Medium | 90% | 64.6% | ||
| #78 | Subsets ArrayBacktrackingBit Manipulation | Medium | 100% | 82.5% | ||
| #268 | Missing Number ArrayHash TableMathBinary SearchBit ManipulationSorting | Easy | 78% | 72.3% | ||
| #136 | Single Number ArrayBit Manipulation | Easy | 75% | 77.9% | ||
| #465 | Optimal Account Balancing ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmask | Hard | 100% | 50.5% | ||
| #191 | Number of 1 Bits Divide and ConquerBit Manipulation | Easy | 88% | 77.1% | ||
| #190 | Reverse Bits Divide and ConquerBit Manipulation | Easy | 76% | 68.8% | ||
| #231 | Power of Two MathBit ManipulationRecursion | Easy | 76% | 50.3% | ||
| #338 | Counting Bits Dynamic ProgrammingBit Manipulation | Easy | 57% | 80.7% | ||
| #371 | Sum of Two Integers MathBit Manipulation | Medium | 100% | 55.8% | ||
| #2035 | Partition Array Into Two Arrays to Minimize Sum Difference ArrayTwo PointersBinary SearchDynamic ProgrammingBit ManipulationMeet in the MiddleSortingOrdered SetBitmask | Hard | 100% | 23.9% | ||
| #473 | Matchsticks to Square ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmask | Medium | 100% | 42.1% | ||
| #2571 | Minimum Operations to Reduce an Integer to 0 Dynamic ProgrammingGreedyBit Manipulation | Medium | 100% | 62.8% | ||
| #342 | Power of Four MathBit ManipulationRecursion | Easy | 90% | 52.3% | ||
| #1404 | Number of Steps to Reduce a Number in Binary Representation to One StringBit ManipulationSimulation | Medium | 88% | 63.7% | ||
| #645 | Set Mismatch ArrayHash TableBit ManipulationSorting | Easy | 88% | 43.4% | ||
| #698 | Partition to K Equal Sum Subsets ArrayDynamic ProgrammingBacktrackingBit ManipulationMemoizationBitmask | Medium | 75% | 38.8% | ||
| #29 | Divide Two Integers MathBit Manipulation | Medium | 75% | 20.0% | ||
| #2220 | Minimum Bit Flips to Convert Number Bit Manipulation | Easy | 100% | 88.0% | ||
| #784 | Letter Case Permutation StringBacktrackingBit Manipulation | Medium | 100% | 75.9% | ||
| #1342 | Number of Steps to Reduce a Number to Zero MathBit Manipulation | Easy | 100% | 85.9% | ||
| #864 | Shortest Path to Get All Keys ArrayBit ManipulationBreadth-First SearchMatrix | Hard | 100% | 54.8% | ||
| #2850 | Minimum Moves to Spread Stones Over Grid ArrayDynamic ProgrammingBacktrackingBit ManipulationMatrixBitmask | Medium | 100% | 45.8% | ||
| #187 | Repeated DNA Sequences Hash TableStringBit ManipulationSliding WindowRolling HashHash FunctionZ AlgorithmBoyer–Moore String-Search Algorithm | Medium | 81% | 53.6% | ||
| #898 | Bitwise ORs of Subarrays ArrayDynamic ProgrammingBit Manipulation | Medium | 75% | 56.9% | ||
| #222 | Count Complete Tree Nodes Binary SearchBit ManipulationTreeBinary Tree | Medium | 68% | 73.1% | ||
| #526 | Beautiful Arrangement ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmask | Medium | 66% | 64.9% | ||
| #260 | Single Number III ArrayBit Manipulation | Medium | 65% | 70.2% | ||
| #2044 | Count Number of Maximum Bitwise-OR Subsets ArrayBacktrackingBit ManipulationEnumeration | Medium | 64% | 89.5% | ||
| #779 | K-th Symbol in Grammar MathBit ManipulationRecursion | Medium | 63% | 48.5% | ||
| #980 | Unique Paths III ArrayBacktrackingBit ManipulationMatrixHamiltonian Path | Hard | 52% | 82.9% | ||
| #1239 | Maximum Length of a Concatenated String with Unique Characters ArrayStringBacktrackingBit Manipulation | Medium | 100% | 54.8% | ||
| #3011 | Find if Array Can Be Sorted ArrayBit ManipulationSorting | Medium | 100% | 66.4% | ||
| #2419 | Longest Subarray With Maximum Bitwise AND ArrayBit ManipulationBrainteaser | Medium | 100% | 65.4% | ||
| #2401 | Longest Nice Subarray ArrayBit ManipulationSliding Window | Medium | 100% | 64.8% | ||
| #2791 | Count Paths That Can Form a Palindrome in a Tree Hash TableBit ManipulationTreeDepth-First Search | Hard | 100% | 0.5% | ||
| #638 | Shopping Offers ArrayDynamic ProgrammingBacktrackingBit ManipulationMemoizationBitmaskKnapsack ProblemComplete Knapsack | Medium | 94% | 52.6% | ||
| #2429 | Minimize XOR GreedyBit Manipulation | Medium | 88% | 62.4% | ||
| #3108 | Minimum Cost Walk in Weighted Graph ArrayBit ManipulationUnion-FindGraph Theory | Hard | 75% | 68.2% | ||
| #2657 | Find the Prefix Common Array of Two Arrays ArrayHash TableBit Manipulation | Medium | 66% | 88.3% | ||
| #805 | Split Array With Same Average ArrayHash TableMathDynamic ProgrammingBit ManipulationMeet in the MiddleBitmask | Hard | 63% | 27.2% | ||
| #3191 | Minimum Operations to Make Binary Array Elements Equal to One I ArrayBit ManipulationQueueSliding WindowPrefix Sum | Medium | 50% | 80.4% | ||
| #832 | Flipping an Image ArrayTwo PointersBit ManipulationMatrixSimulation | Easy | 42% | 83.9% | ||
| #389 | Find the Difference Hash TableStringBit ManipulationSorting | Easy | 42% | 60.5% | ||
| #1930 | Unique Length-3 Palindromic Subsequences Hash TableStringBit ManipulationPrefix Sum | Medium | 39% | 73.8% | ||
| #1371 | Find the Longest Substring Containing Vowels in Even Counts Hash TableStringBit ManipulationPrefix Sum | Medium | 38% | 75.6% | ||
| #405 | Convert a Number to Hexadecimal MathStringBit Manipulation | Easy | 25% | 54.5% | ||
| #1009 | Complement of Base 10 Integer Bit Manipulation | Easy | 100% | 63.4% | ||
| #3513 | Number of Unique XOR Triplets I ArrayMathBit Manipulation | Medium | 100% | 0.6% | ||
| #397 | Integer Replacement Dynamic ProgrammingGreedyBit ManipulationMemoization | Medium | 100% | 0.4% | ||
| #3314 | Construct the Minimum Bitwise Array I ArrayBit Manipulation | Easy | 100% | 85.3% | ||
| #693 | Binary Number with Alternating Bits Bit Manipulation | Easy | 100% | 69.9% | ||
| #2275 | Largest Combination With Bitwise AND Greater Than Zero ArrayHash TableBit ManipulationCounting | Medium | 97% | 0.8% | ||
| #2939 | Maximum Xor Product MathGreedyBit Manipulation | Medium | 94% | 30.2% | ||
| #1611 | Minimum One Bit Operations to Make Integers Zero MathDynamic ProgrammingBit ManipulationRecursionMemoization | Hard | 91% | 78.3% | ||
| #1386 | Cinema Seat Allocation ArrayHash TableGreedyBit Manipulation | Medium | 88% | 44.7% | ||
| #2438 | Range Product Queries of Powers ArrayBit ManipulationPrefix Sum | Medium | 68% | 61.2% | ||
| #393 | UTF-8 Validation ArrayBit Manipulation | Medium | 63% | 46.4% | ||
| #3211 | Generate Binary Strings Without Adjacent Zeros StringBacktrackingBit Manipulation | Medium | 59% | 0.9% | ||
| #1461 | Check If a String Contains All Binary Codes of Size K Hash TableStringBit ManipulationRolling HashHash FunctionDirected Acyclic Graph | Medium | 55% | 61.6% | ||
| #464 | Can I Win MathDynamic ProgrammingBit ManipulationMemoizationGame TheoryBitmask | Medium | 54% | 31.5% | ||
| #1723 | Find Minimum Time to Finish All Jobs ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmask | Hard | 53% | 46.0% | ||
| #1863 | Sum of All Subset XOR Totals ArrayMathBacktrackingBit ManipulationCombinatoricsEnumeration | Easy | 52% | 90.1% | ||
| #266 | Palindrome Permutation Hash TableStringBit Manipulation | Easy | 50% | 68.7% | ||
| #137 | Single Number II ArrayBit Manipulation | Medium | 41% | 67.4% | ||
| #421 | Maximum XOR of Two Numbers in an Array ArrayHash TableBit ManipulationTrie | Medium | 38% | 53.6% | ||
| #2206 | Divide Array Into Equal Pairs ArrayHash TableBit ManipulationCounting | Easy | 38% | 79.3% | ||
| #89 | Gray Code MathBacktrackingBit Manipulation | Medium | 38% | 65.3% | ||
| #3304 | Find the K-th Character in String Game I MathBit ManipulationRecursionSimulation | Easy | 25% | 81.5% | ||
| #401 | Binary Watch BacktrackingBit Manipulation | Easy | 25% | 65.8% | ||
| #2411 | Smallest Subarrays With Maximum Bitwise OR ArrayBinary SearchBit ManipulationSliding Window | Medium | 25% | 61.9% | ||
| #201 | Bitwise AND of Numbers Range Bit Manipulation | Medium | 16% | 49.1% | ||
| #751 | IP to CIDR StringBit Manipulation | Medium | 100% | 53.8% | ||
| #3068 | Find the Maximum Sum of Node Values ArrayDynamic ProgrammingGreedyBit ManipulationTreeSorting | Hard | 100% | 69.4% | ||
| #3097 | Shortest Subarray With OR at Least K II ArrayBit ManipulationSliding Window | Medium | 100% | 50.2% | ||
| #3495 | Minimum Operations to Make Array Elements Zero ArrayMathBit Manipulation | Hard | 100% | 60.3% | ||
| #3315 | Construct the Minimum Bitwise Array II ArrayBit Manipulation | Medium | 100% | 66.6% | ||
| #1356 | Sort Integers by The Number of 1 Bits ArrayBit ManipulationSortingCounting | Easy | 100% | 82.4% | ||
| #491 | Non-decreasing Subsequences ArrayHash TableBacktrackingBit Manipulation | Medium | 100% | 62.9% | ||
| #691 | Stickers to Spell Word ArrayHash TableStringDynamic ProgrammingBacktrackingBit ManipulationMemoizationBitmask | Hard | 89% | 51.0% | ||
| #2433 | Find The Original Array of Prefix Xor ArrayBit Manipulation | Medium | 88% | 88.4% | ||
| #2506 | Count Pairs Of Similar Strings ArrayHash TableStringBit ManipulationCounting | Easy | 63% | 73.8% | ||
| #847 | Shortest Path Visiting All Nodes Dynamic ProgrammingBit ManipulationBreadth-First SearchGraph TheoryBitmask | Hard | 38% | 66.1% | ||
| #1763 | Longest Nice Substring Hash TableStringDivide and ConquerBit ManipulationSliding Window | Easy | 38% | 64.5% | ||
| #1483 | Kth Ancestor of a Tree Node Binary SearchDynamic ProgrammingBit ManipulationTreeDepth-First SearchBreadth-First SearchDesignBinary Lifting | Hard | 27% | 38.9% | ||
| #461 | Hamming Distance Bit Manipulation | Easy | 25% | 76.9% | ||
| #2322 | Minimum Score After Removals on a Tree ArrayBit ManipulationTreeDepth-First Search | Hard | 25% | 76.1% | ||
| #2749 | Minimum Operations to Make the Integer Zero Bit ManipulationBrainteaserEnumeration | Medium | 18% | 58.2% | ||
| #3534 | Path Existence Queries in a Graph II ArrayTwo PointersBinary SearchDynamic ProgrammingGreedyBit ManipulationGraph TheorySorting | Hard | 15% | 64.6% | ||
| #3133 | Minimum Array End Bit Manipulation | Medium | 13% | 55.5% | ||
| #1434 | Number of Ways to Wear Different Hats to Each Other ArrayDynamic ProgrammingBit ManipulationBitmaskBipartite GraphMatching (Graph)Perfect Matching | Hard | 100% | 46.4% | ||
| #1684 | Count the Number of Consistent Strings ArrayHash TableStringBit ManipulationCounting | Easy | 100% | 88.5% | ||
| #2425 | Bitwise XOR of All Pairings ArrayBit ManipulationBrainteaser | Medium | 100% | 66.9% | ||
| #2151 | Maximum Good People Based on Statements ArrayBacktrackingBit ManipulationEnumeration | Hard | 100% | 52.6% | ||
| #810 | Chalkboard XOR Game ArrayMathBit ManipulationBrainteaserGame TheoryZero-Sum GameImpartial Game | Hard | 100% | 66.8% | ||
| #861 | Score After Flipping Matrix ArrayGreedyBit ManipulationMatrix | Medium | 100% | 80.3% | ||
| #1310 | XOR Queries of a Subarray ArrayBit ManipulationPrefix Sum | Medium | 100% | 78.0% | ||
| #3514 | Number of Unique XOR Triplets II ArrayMathBit ManipulationEnumeration | Medium | 100% | 0.5% | ||
| #1349 | Maximum Students Taking Exam ArrayDynamic ProgrammingBit ManipulationMatrixBitmaskMaximum FlowMaximum MatchingBipartite GraphEdmonds–Karp AlgorithmMPM AlgorithmPush-Relabel AlgorithmMinimum CutMatching (Graph)Flow NetworkDinic's Algorithm | Hard | 92% | 54.0% | ||
| #1755 | Closest Subsequence Sum ArrayTwo PointersDynamic ProgrammingBit ManipulationMeet in the MiddleSortingBitmask | Hard | 90% | 44.0% | ||
| #3878 | Count Good Subarrays ArrayStackBit ManipulationMonotonic Stack | Hard | 89% | 25.5% | ||
| #2032 | Two Out of Three ArrayHash TableBit Manipulation | Easy | 88% | 0.8% | ||
| #756 | Pyramid Transition Matrix Hash TableStringBacktrackingBit Manipulation | Medium | 75% | 60.6% | ||
| #1494 | Parallel Courses II Dynamic ProgrammingBit ManipulationGraph TheoryBitmaskDirected Acyclic Graph | Hard | 50% | 31.1% | ||
| #477 | Total Hamming Distance ArrayMathBit Manipulation | Medium | 39% | 55.1% | ||
| #3702 | Longest Subsequence With Non-Zero Bitwise XOR ArrayBit Manipulation | Medium | 31% | 0.6% | ||
| #1255 | Maximum Score Words Formed by Letters ArrayHash TableStringDynamic ProgrammingBacktrackingBit ManipulationCountingBitmask | Hard | 25% | 81.5% | ||
| #1680 | Concatenation of Consecutive Binary Numbers MathBit ManipulationSimulation | Medium | 25% | 66.7% | ||
| #1506 | Find Root of N-Ary Tree Hash TableBit ManipulationTreeDepth-First Search | Medium | 25% | 78.6% | ||
| #995 | Minimum Number of K Consecutive Bit Flips ArrayBit ManipulationQueueSliding WindowPrefix SumBrute-Force Search | Hard | 16% | 0.6% | ||
| #3370 | Smallest Number With All Set Bits MathBit Manipulation | Easy | 16% | 80.3% | ||
| #3307 | Find the K-th Character in String Game II MathBit ManipulationRecursion | Hard | 13% | 48.4% | ||
| #3559 | Number of Ways to Assign Edge Weights II ArrayMathDynamic ProgrammingBit ManipulationTreeDepth-First Search | Hard | 13% | 72.5% | ||
| #1018 | Binary Prefix Divisible By 5 ArrayBit Manipulation | Easy | 13% | 53.7% | ||
| #1457 | Pseudo-Palindromic Paths in a Binary Tree Bit ManipulationTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 100% | 68.4% | ||
| #2317 | Maximum XOR After Operations ArrayMathBit Manipulation | Medium | 100% | 80.0% | ||
| #1799 | Maximize Score After N Operations ArrayMathDynamic ProgrammingBacktrackingBit ManipulationNumber TheoryBitmask | Hard | 97% | 57.9% | ||
| #1486 | XOR Operation in an Array MathBit Manipulation | Easy | 88% | 87.7% | ||
| #2184 | Number of Ways to Build Sturdy Brick Wall ArrayDynamic ProgrammingBit ManipulationBitmask | Medium | 69% | 49.5% | ||
| #1986 | Minimum Number of Work Sessions to Finish the Tasks ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmask | Medium | 63% | 35.1% | ||
| #996 | Number of Squareful Arrays ArrayHash TableMathDynamic ProgrammingBacktrackingBit ManipulationBitmask | Hard | 51% | 51.6% | ||
| #782 | Transform to Chessboard ArrayMathBit ManipulationMatrix | Hard | 50% | 51.6% | ||
| #1125 | Smallest Sufficient Team ArrayDynamic ProgrammingBit ManipulationBitmask | Hard | 50% | 0.6% | ||
| #1829 | Maximum XOR for Each Query ArrayBit ManipulationPrefix Sum | Medium | 50% | 84.7% | ||
| #2305 | Fair Distribution of Cookies ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmask | Medium | 39% | 70.0% | ||
| #943 | Find the Shortest Superstring ArrayStringDynamic ProgrammingBit ManipulationBitmaskHamiltonian Path | Hard | 38% | 45.5% | ||
| #3539 | Find Sum of Array Product of Magical Sequences ArrayMathDynamic ProgrammingBit ManipulationCombinatoricsBitmask | Hard | 38% | 61.7% | ||
| #1318 | Minimum Flips to Make a OR b Equal to c Bit Manipulation | Medium | 38% | 72.0% | ||
| #3688 | Bitwise OR of Even Numbers in an Array ArrayBit ManipulationSimulation | Easy | 27% | 85.3% | ||
| #2351 | First Letter to Appear Twice Hash TableStringBit ManipulationCounting | Easy | 26% | 75.1% | ||
| #318 | Maximum Product of Word Lengths ArrayStringBit Manipulation | Medium | 25% | 61.4% | ||
| #1947 | Maximum Compatibility Score Sum ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmaskHungarian AlgorithmBipartite GraphSuccessive Shortest Path AlgorithmMatching (Graph)Perfect MatchingMinimum-Cost FlowFlow Network | Medium | 25% | 64.7% | ||
| #762 | Prime Number of Set Bits in Binary Representation MathBit ManipulationPrimality Test | Easy | 25% | 78.9% | ||
| #1525 | Number of Good Ways to Split a String Hash TableStringDynamic ProgrammingBit ManipulationPrefix Sum | Medium | 25% | 68.5% | ||
| #411 | Minimum Unique Word Abbreviation ArrayStringBacktrackingBit Manipulation | Hard | 25% | 40.5% | ||
| #1915 | Number of Wonderful Substrings Hash TableStringBit ManipulationPrefix Sum | Medium | 25% | 66.6% | ||
| #3158 | Find the XOR of Numbers Which Appear Twice ArrayHash TableBit Manipulation | Easy | 13% | 79.2% | ||
| #1442 | Count Triplets That Can Form Two Arrays of Equal XOR ArrayHash TableMathBit ManipulationPrefix Sum | Medium | 13% | 84.8% | ||
| #2595 | Number of Even and Odd Bits Bit Manipulation | Easy | 13% | 0.7% | ||
| #2683 | Neighboring Bitwise XOR ArrayBit Manipulation | Medium | 13% | 79.8% | ||
| #3309 | Maximum Possible Number by Binary Concatenation ArrayBit ManipulationEnumeration | Medium | 13% | 65.6% | ||
| #1542 | Find Longest Awesome Substring Hash TableStringBit Manipulation | Hard | 100% | 47.2% | ||
| #2564 | Substring XOR Queries ArrayHash TableStringBit Manipulation | Medium | 100% | 35.8% | ||
| #2403 | Minimum Time to Kill All Monsters ArrayDynamic ProgrammingBit ManipulationBitmask | Hard | 100% | 57.7% | ||
| #2212 | Maximum Points in an Archery Competition ArrayBacktrackingBit ManipulationEnumeration | Medium | 100% | 52.3% | ||
| #1256 | Encode Number MathStringBit Manipulation | Medium | 100% | 70.3% | ||
| #2932 | Maximum Strong Pair XOR I ArrayHash TableBit ManipulationTrieSliding Window | Easy | 100% | 76.3% | ||
| #2935 | Maximum Strong Pair XOR II ArrayHash TableBit ManipulationTrieSliding Window | Hard | 100% | 33.2% | ||
| #3180 | Maximum Total Reward Using Operations I ArrayDynamic ProgrammingBit ManipulationSorting | Medium | 100% | 31.1% | ||
| #3181 | Maximum Total Reward Using Operations II ArrayDynamic ProgrammingBit ManipulationSorting | Hard | 100% | 22.0% | ||
| #3095 | Shortest Subarray With OR at Least K I ArrayBit ManipulationSliding Window | Easy | 100% | 44.8% | ||
| #1803 | Count Pairs With XOR in a Range ArrayBit ManipulationTrie | Hard | 100% | 46.5% | ||
| #3435 | Frequencies of Shortest Supersequences ArrayStringBit ManipulationGraph TheoryTopological SortEnumeration | Hard | 100% | 22.8% | ||
| #1178 | Number of Valid Words for Each Puzzle ArrayHash TableStringBit ManipulationTrie | Hard | 100% | 47.9% | ||
| #1521 | Find a Value of a Mysterious Function Closest to Target ArrayBinary SearchBit ManipulationSegment TreeSparse Table | Hard | 100% | 47.4% | ||
| #3003 | Maximize the Number of Partitions After Operations StringDynamic ProgrammingBit ManipulationBitmask | Hard | 100% | 53.4% | ||
| #3376 | Minimum Time to Break Locks I ArrayDynamic ProgrammingBacktrackingBit ManipulationBreadth-First SearchBitmask | Medium | 100% | 32.8% | ||
| #3226 | Number of Bit Changes to Make Two Integers Equal Bit Manipulation | Easy | 100% | 63.6% | ||
| #1177 | Can Make Palindrome from Substring ArrayHash TableStringBit ManipulationPrefix Sum | Medium | 100% | 41.8% | ||
| #2505 | Bitwise OR of All Subsequence Sums ArrayMathBit ManipulationBrainteaserPrefix Sum | Medium | 100% | 64.1% | ||
| #2869 | Minimum Operations to Collect Elements ArrayHash TableBit Manipulation | Easy | 100% | 62.6% | ||
| #3766 | Minimum Operations to Make Binary Palindrome ArrayTwo PointersBinary SearchBit Manipulation | Medium | 100% | 52.2% | ||
| #2846 | Minimum Edge Weight Equilibrium Queries in a Tree ArrayDynamic ProgrammingBit ManipulationTreeDepth-First Search | Hard | 90% | 47.0% | ||
| #2546 | Apply Bitwise Operations to Make Strings Equal StringBit Manipulation | Medium | 90% | 42.8% | ||
| #2897 | Apply Operations on Array to Maximize Sum of Squares ArrayHash TableGreedyBit Manipulation | Hard | 90% | 44.9% | ||
| #3022 | Minimize OR of Remaining Elements Using Operations ArrayGreedyBit Manipulation | Hard | 89% | 30.8% | ||
| #2152 | Minimum Number of Lines to Cover Points ArrayHash TableMathDynamic ProgrammingBacktrackingBit ManipulationGeometryBitmask | Medium | 88% | 44.1% | ||
| #2859 | Sum of Values at Indices With K Set Bits ArrayBit Manipulation | Easy | 88% | 86.2% | ||
| #3173 | Bitwise OR of Adjacent Elements ArrayBit Manipulation | Easy | 88% | 94.7% | ||
| #1238 | Circular Permutation in Binary Representation MathBacktrackingBit Manipulation | Medium | 88% | 72.8% | ||
| #3827 | Count Monobit Integers Bit ManipulationEnumeration | Easy | 76% | 66.6% | ||
| #2920 | Maximum Points After Collecting Coins From All Nodes ArrayDynamic ProgrammingBit ManipulationTreeDepth-First SearchMemoizationDP on Trees | Hard | 75% | 36.9% | ||
| #3209 | Number of Subarrays With AND Value of K ArrayBinary SearchBit ManipulationSegment Tree | Hard | 75% | 35.6% | ||
| #1284 | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix ArrayHash TableBit ManipulationBreadth-First SearchMatrix | Hard | 75% | 72.9% | ||
| #3575 | Maximum Good Subtree Score ArrayDynamic ProgrammingBit ManipulationTreeDepth-First SearchBitmask | Hard | 75% | 45.7% | ||
| #3145 | Find Products of Elements of Big Array ArrayBinary SearchBit Manipulation | Hard | 65% | 25.1% | ||
| #2836 | Maximize Value of Function in a Ball Passing Game ArrayDynamic ProgrammingBit Manipulation | Hard | 63% | 31.5% | ||
| #2992 | Number of Self-Divisible Permutations ArrayMathDynamic ProgrammingBacktrackingBit ManipulationNumber TheoryBitmask | Medium | 63% | 72.1% | ||
| #3171 | Find Subarray With Bitwise OR Closest to K ArrayBinary SearchBit ManipulationSegment Tree | Hard | 63% | 31.4% | ||
| #1659 | Maximize Grid Happiness Dynamic ProgrammingBit ManipulationMemoizationBitmask | Hard | 63% | 41.3% | ||
| #2397 | Maximum Rows Covered by Columns ArrayBacktrackingBit ManipulationMatrixEnumeration | Medium | 50% | 58.2% | ||
| #3644 | Maximum K to Sort a Permutation ArrayBit Manipulation | Medium | 38% | 37.5% | ||
| #672 | Bulb Switcher II MathBit ManipulationDepth-First SearchBreadth-First Search | Medium | 38% | 50.4% | ||
| #3646 | Next Special Palindrome Number BacktrackingBit Manipulation | Hard | 38% | 28.3% | ||
| #351 | Android Unlock Patterns Dynamic ProgrammingBacktrackingBit ManipulationBitmask | Medium | 38% | 53.9% | ||
| #3393 | Count Paths With the Given XOR Value ArrayDynamic ProgrammingBit ManipulationMatrix | Medium | 31% | 40.8% | ||
| #1681 | Minimum Incompatibility ArrayHash TableDynamic ProgrammingBit ManipulationBitmask | Hard | 27% | 41.4% | ||
| #3806 | Maximum Bitwise AND After Increment Operations ArrayGreedyBit ManipulationSorting | Hard | 25% | 32.2% | ||
| #957 | Prison Cells After N Days ArrayHash TableMathBit ManipulationFloyd's Cycle Finding Algorithm | Medium | 25% | 39.2% | ||
| #1601 | Maximum Number of Achievable Transfer Requests ArrayBacktrackingBit ManipulationEnumeration | Hard | 25% | 64.8% | ||
| #2917 | Find the K-or of an Array ArrayBit Manipulation | Easy | 25% | 73.0% | ||
| #3154 | Find Number of Ways to Reach the K-th Stair MathDynamic ProgrammingBit ManipulationMemoizationCombinatorics | Hard | 25% | 38.0% | ||
| #1558 | Minimum Numbers of Function Calls to Make Target Array ArrayGreedyBit Manipulation | Medium | 25% | 62.8% | ||
| #1734 | Decode XORed Permutation ArrayBit Manipulation | Medium | 25% | 67.2% | ||
| #2527 | Find Xor-Beauty of Array ArrayMathBit Manipulation | Medium | 25% | 71.1% | ||
| #3199 | Count Triplets with Even XOR Set Bits I ArrayBit Manipulation | Easy | 25% | 82.9% | ||
| #3215 | Count Triplets with Even XOR Set Bits II ArrayBit Manipulation | Medium | 25% | 61.8% | ||
| #1707 | Maximum XOR With an Element From Array ArrayBit ManipulationTrie | Hard | 25% | 58.9% | ||
| #3287 | Find the Maximum Sequence Value of Array ArrayDynamic ProgrammingBit Manipulation | Hard | 25% | 22.1% | ||
| #1595 | Minimum Cost to Connect Two Groups of Points ArrayDynamic ProgrammingBit ManipulationMatrixBitmaskBipartite GraphSuccessive Shortest Path AlgorithmMatching (Graph)Minimum-Cost FlowFlow Network | Hard | 25% | 50.4% | ||
| #1655 | Distribute Repeating Integers ArrayHash TableDynamic ProgrammingBacktrackingBit ManipulationCountingBitmask | Hard | 25% | 41.0% | ||
| #1738 | Find Kth Largest XOR Coordinate Value ArrayDivide and ConquerBit ManipulationSortingHeap (Priority Queue)MatrixPrefix SumQuickselect | Medium | 25% | 64.4% | ||
| #1815 | Maximum Number of Groups Getting Fresh Donuts ArrayDynamic ProgrammingBit ManipulationMemoizationBitmask | Hard | 25% | 41.5% | ||
| #2172 | Maximum AND Sum of Array ArrayDynamic ProgrammingBit ManipulationBitmask | Hard | 25% | 50.9% | ||
| #320 | Generalized Abbreviation StringBacktrackingBit Manipulation | Medium | 25% | 60.5% | ||
| #1066 | Campus Bikes II ArrayDynamic ProgrammingBacktrackingBit ManipulationBitmaskHungarian AlgorithmBipartite GraphSuccessive Shortest Path AlgorithmMatching (Graph)Minimum-Cost FlowFlow Network | Medium | 25% | 55.9% | ||
| #2135 | Count Words Obtained After Adding a Letter ArrayHash TableStringBit ManipulationSorting | Medium | 25% | 44.2% | ||
| #2128 | Remove All Ones With Row and Column Flips ArrayMathBit ManipulationMatrix | Medium | 25% | 76.2% | ||
| #2174 | Remove All Ones With Row and Column Flips II ArrayBit ManipulationBreadth-First SearchMatrix | Medium | 25% | 67.4% | ||
| #2857 | Count Pairs of Points With Distance k ArrayHash TableBit Manipulation | Medium | 25% | 33.2% | ||
| #3117 | Minimum Sum of Values by Dividing Array ArrayBinary SearchDynamic ProgrammingBit ManipulationSegment TreeQueue | Hard | 25% | 27.9% | ||
| #3858 | Minimum Bitwise OR From Grid ArrayGreedyBit ManipulationMatrix | Medium | 18% | 27.4% | ||
| #3149 | Find the Minimum Cost Array Permutation ArrayDynamic ProgrammingBit ManipulationBitmask | Hard | 15% | 26.0% | ||
| #3533 | Concatenated Divisibility ArrayDynamic ProgrammingBit ManipulationBitmask | Hard | 13% | 31.2% | ||
| #3566 | Partition Array into Two Equal Product Subsets ArrayBit ManipulationRecursionEnumeration | Medium | 13% | 35.3% | ||
| #2568 | Minimum Impossible OR ArrayBit ManipulationBrainteaser | Medium | 13% | 59.3% | ||
| #3568 | Minimum Moves to Clean the Classroom ArrayHash TableBit ManipulationBreadth-First SearchMatrix | Medium | 13% | 26.9% | ||
| #2306 | Naming a Company ArrayHash TableStringBit ManipulationEnumeration | Hard | 13% | 46.6% | ||
| #3585 | Find Weighted Median Node in Tree ArrayBinary SearchDynamic ProgrammingBit ManipulationTreeDepth-First Search | Hard | 13% | 26.2% | ||
| #3821 | Find Nth Smallest Integer With K One Bits MathBit ManipulationCombinatorics | Hard | 13% | 35.3% | ||
| #3630 | Partition Array for Maximum XOR and AND ArrayMathGreedyBit ManipulationEnumeration | Hard | 13% | 17.9% | ||
| #3283 | Maximum Number of Moves to Kill All Pawns ArrayMathBit ManipulationBreadth-First SearchGame TheoryBitmask | Hard | 13% | 34.2% | ||
| #3599 | Partition Array to Minimize XOR ArrayDynamic ProgrammingBit ManipulationPrefix Sum | Medium | 13% | 41.6% | ||
| #3882 | Minimum XOR Path in a Grid ArrayDynamic ProgrammingBit ManipulationMatrix | Medium | 13% | 39.9% | ||
| #3615 | Longest Palindromic Path in Graph StringDynamic ProgrammingBit ManipulationGraph TheoryBitmask | Hard | 13% | 22.5% | ||
| #1720 | Decode XORed Array ArrayBit Manipulation | Easy | 13% | 87.5% |
Showing 226 of 226 problems in Bit ManipulationFiltered: All Companies