Bit Manipulation Pattern: Template + 194 LeetCode Problems
Use XOR, masks and the low-bit trick to replace whole data structures with an integer.
- 40 Easy
- 96 Medium
- 58 Hard
- O(n) for a scan, O(2ⁿ) for subset enumeration time
What the bit manipulation pattern is
Bit manipulation problems reduce to a handful of identities that are worth knowing cold. XOR is its own inverse and is commutative, so xor-ing an entire array cancels every value that appears twice and leaves the one that does not — no hash map, no extra space. `x & (x - 1)` clears the lowest set bit, which counts set bits in as many iterations as there are ones rather than thirty-two, and instantly tests for a power of two. `x & -x` isolates that lowest set bit instead of clearing it. The second, larger use is the bitmask as a set: an integer's bits stand for membership, so a subset of up to twenty elements fits in one machine word, subsets can be enumerated by counting from zero to 2ⁿ, and a dynamic programming state can be indexed by which items have been used. Python integers have no fixed width and no overflow, which removes a whole class of bugs but also means a shift left never wraps and negative numbers behave as if they had infinitely many leading ones.
When to use it
- Every element appears a fixed number of times except one — XOR or per-bit counting finds it.
- The problem is about set bits, powers of two, or a specific bit position.
- n is at most about twenty and you need to iterate over subsets or track which items are used.
- A boolean set must be stored and compared cheaply, as a dynamic programming key.
The bit manipulation template in Python
The shape, not a solution to any one problem. Adapt the condition and the summary being maintained; the skeleton stays the same across the 194 problems listed below.
def single_number(nums):
"""Pairs cancel under XOR, so the odd one out survives."""
result = 0
for value in nums:
result ^= value
return result
def count_set_bits(x):
total = 0
while x:
x &= x - 1 # clears the lowest set bit, so this runs once per 1
total += 1
return totalComplexity characteristics
- Time
- O(n) for a scan, O(2ⁿ) for subset enumeration
- Auxiliary space
- O(1)
The XOR cancellation scan is one pass with a single accumulator: linear time, constant space, no hash map. Counting set bits with x & (x − 1) runs once per set bit rather than once per bit position, so it is O(popcount) instead of O(word size). Bitmask enumeration is O(2ⁿ) by definition and bitmask dynamic programming is O(2ⁿ·n), which is why these problems cap n at around twenty.
All 194 bit manipulation LeetCode problems
Every problem in the library the bit manipulation pattern applies to, grouped by LeetCode's own difficulty rating. 173 of the 194 carry a complete Python solution with a worked example and complexity analysis; the rest are listed for completeness, with the LeetCode Premium ones marked.
Easy (40)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 67 | Add Binary | Easy | Bit Manipulation, Math, String +1 |
| 136 | Single Number | Easy | Bit Manipulation, Array |
| 190 | Reverse Bits | Easy | Bit Manipulation, Divide and Conquer |
| 191 | Number of 1 Bits | Easy | Bit Manipulation, Divide and Conquer |
| 222 | Count Complete Tree Nodes | Easy | Bit Manipulation, Tree, Binary Search +1 |
| 231 | Power of Two | Easy | Bit Manipulation, Recursion, Math |
| 268 | Missing Number | Easy | Bit Manipulation, Array, Hash Table +3 |
| 338 | Counting Bits | Easy | Bit Manipulation, Dynamic Programming |
| 342 | Power of Four | Easy | Bit Manipulation, Recursion, Math |
| 389 | Find the Difference | Easy | Bit Manipulation, Hash Table, String +1 |
| 401 | Binary Watch | Easy | Bit Manipulation, Backtracking |
| 405 | Convert a Number to Hexadecimal | Easy | Bit Manipulation, Math, String |
| 461 | Hamming Distance | Easy | Bit Manipulation |
| 476 | Number Complement | Easy | Bit Manipulation |
| 645 | Set Mismatch | Easy | Bit Manipulation, Array, Hash Table +1 |
| 693 | Binary Number with Alternating Bits | Easy | Bit Manipulation |
| 266 | Palindrome PermutationPremium | Easy | Bit Manipulation, Hash Table, String |
| 762 | Prime Number of Set Bits in Binary Representation | Easy | Bit Manipulation, Math |
| 832 | Flipping an Image | Easy | Bit Manipulation, Array, Two Pointers +2 |
| 868 | Binary Gap | Easy | Bit Manipulation |
| 1009 | Complement of Base 10 Integer | Easy | Bit Manipulation |
| 1018 | Binary Prefix Divisible By 5 | Easy | Bit Manipulation, Array |
| 1342 | Number of Steps to Reduce a Number to Zero | Easy | Bit Manipulation, Math |
| 1356 | Sort Integers by The Number of 1 Bits | Easy | Bit Manipulation, Array, Counting +1 |
| 1486 | XOR Operation in an Array | Easy | Bit Manipulation, Math |
| 1684 | Count the Number of Consistent Strings | Easy | Bit Manipulation, Array, Hash Table +2 |
| 1720 | Decode XORed Array | Easy | Bit Manipulation, Array |
| 1763 | Longest Nice Substring | Easy | Bit Manipulation, Hash Table, String +2 |
| 1863 | Sum of All Subset XOR Totals | Easy | Bit Manipulation, Array, Math +3 |
| 2032 | Two Out of Three | Easy | Bit Manipulation, Array, Hash Table |
| 2206 | Divide Array Into Equal Pairs | Easy | Bit Manipulation, Array, Hash Table +1 |
| 2220 | Minimum Bit Flips to Convert Number | Easy | Bit Manipulation |
| 2351 | First Letter to Appear Twice | Easy | Bit Manipulation, Hash Table, String +1 |
| 2506 | Count Pairs Of Similar Strings | Easy | Bit Manipulation, Array, Hash Table +2 |
| 2595 | Number of Even and Odd Bits | Easy | Bit Manipulation |
| 2859 | Sum of Values at Indices With K Set Bits | Easy | Bit Manipulation, Array |
| 2869 | Minimum Operations to Collect Elements | Easy | Bit Manipulation, Array, Hash Table |
| 2917 | Find the K-or of an Array | Easy | Bit Manipulation, Array |
| 2932 | Maximum Strong Pair XOR I | Easy | Bit Manipulation, Trie, Array +2 |
| 2980 | Check if Bitwise OR Has Trailing Zeros | Easy | Bit Manipulation, Array |
Medium (96)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 29 | Divide Two Integers | Medium | Bit Manipulation, Math |
| 78 | Subsets | Medium | Bit Manipulation, Array, Backtracking |
| 89 | Gray Code | Medium | Bit Manipulation, Math, Backtracking |
| 90 | Subsets II | Medium | Bit Manipulation, Array, Backtracking |
| 137 | Single Number II | Medium | Bit Manipulation, Array |
| 187 | Repeated DNA Sequences | Medium | Bit Manipulation, Hash Table, String +3 |
| 201 | Bitwise AND of Numbers Range | Medium | Bit Manipulation |
| 260 | Single Number III | Medium | Bit Manipulation, Array |
| 287 | Find the Duplicate Number | Medium | Bit Manipulation, Array, Two Pointers +1 |
| 318 | Maximum Product of Word Lengths | Medium | Bit Manipulation, Array, String |
| 371 | Sum of Two Integers | Medium | Bit Manipulation, Math |
| 393 | UTF-8 Validation | Medium | Bit Manipulation, Array |
| 397 | Integer Replacement | Medium | Greedy, Bit Manipulation, Memoization +1 |
| 421 | Maximum XOR of Two Numbers in an Array | Medium | Bit Manipulation, Trie, Array +1 |
| 464 | Can I Win | Medium | Bit Manipulation, Memoization, Math +3 |
| 473 | Matchsticks to Square | Medium | Bit Manipulation, Array, Dynamic Programming +2 |
| 477 | Total Hamming Distance | Medium | Bit Manipulation, Array, Math |
| 491 | Non-decreasing Subsequences | Medium | Bit Manipulation, Array, Hash Table +1 |
| 526 | Beautiful Arrangement | Medium | Bit Manipulation, Array, Dynamic Programming +2 |
| 638 | Shopping Offers | Medium | Bit Manipulation, Memoization, Array +3 |
| 672 | Bulb Switcher II | Medium | Bit Manipulation, Depth-First Search, Breadth-First Search +1 |
| 698 | Partition to K Equal Sum Subsets | Medium | Bit Manipulation, Memoization, Array +3 |
| 1318 | Minimum Flips to Make a OR b Equal to c | Medium | Bit Manipulation |
| 320 | Generalized AbbreviationPremium | Medium | Bit Manipulation, String, Backtracking |
| 351 | Android Unlock PatternsPremium | Medium | Bit Manipulation, Dynamic Programming, Backtracking +1 |
| 751 | IP to CIDRPremium | Medium | Bit Manipulation, String |
| 756 | Pyramid Transition Matrix | Medium | Bit Manipulation, Hash Table, String +1 |
| 779 | K-th Symbol in Grammar | Medium | Bit Manipulation, Recursion, Math |
| 784 | Letter Case Permutation | Medium | Bit Manipulation, String, Backtracking |
| 861 | Score After Flipping Matrix | Medium | Greedy, Bit Manipulation, Array +1 |
| 898 | Bitwise ORs of Subarrays | Medium | Bit Manipulation, Array, Dynamic Programming |
| 957 | Prison Cells After N Days | Medium | Bit Manipulation, Array, Hash Table +1 |
| 1016 | Binary String With Substrings Representing 1 To N | Medium | Bit Manipulation, Hash Table, String +1 |
| 1066 | Campus Bikes IIPremium | Medium | Bit Manipulation, Array, Dynamic Programming +2 |
| 1177 | Can Make Palindrome from Substring | Medium | Bit Manipulation, Array, Hash Table +2 |
| 1238 | Circular Permutation in Binary Representation | Medium | Bit Manipulation, Math, Backtracking |
| 1239 | Maximum Length of a Concatenated String with Unique Characters | Medium | Bit Manipulation, Array, String +1 |
| 1256 | Encode NumberPremium | Medium | Bit Manipulation, Math, String |
| 1310 | XOR Queries of a Subarray | Medium | Bit Manipulation, Array, Prefix Sum |
| 1371 | Find the Longest Substring Containing Vowels in Even Counts | Medium | Bit Manipulation, Hash Table, String +1 |
| 1386 | Cinema Seat Allocation | Medium | Greedy, Bit Manipulation, Array +1 |
| 1404 | Number of Steps to Reduce a Number in Binary Representation to One | Medium | Bit Manipulation, String, Simulation |
| 1442 | Count Triplets That Can Form Two Arrays of Equal XOR | Medium | Bit Manipulation, Array, Hash Table +2 |
| 1457 | Pseudo-Palindromic Paths in a Binary Tree | Medium | Bit Manipulation, Tree, Depth-First Search +2 |
| 1461 | Check If a String Contains All Binary Codes of Size K | Medium | Bit Manipulation, Hash Table, String +2 |
| 1506 | Find Root of N-Ary TreePremium | Medium | Bit Manipulation, Tree, Depth-First Search +1 |
| 1525 | Number of Good Ways to Split a String | Medium | Bit Manipulation, Hash Table, String +1 |
| 1558 | Minimum Numbers of Function Calls to Make Target Array | Medium | Greedy, Bit Manipulation, Array |
| 1680 | Concatenation of Consecutive Binary Numbers | Medium | Bit Manipulation, Math, Simulation |
| 1734 | Decode XORed Permutation | Medium | Bit Manipulation, Array |
| 1738 | Find Kth Largest XOR Coordinate Value | Medium | Bit Manipulation, Array, Divide and Conquer +5 |
| 1829 | Maximum XOR for Each Query | Medium | Bit Manipulation, Array, Prefix Sum |
| 1908 | Game of NimPremium | Medium | Bit Manipulation, Brainteaser, Array +3 |
| 1915 | Number of Wonderful Substrings | Medium | Bit Manipulation, Hash Table, String +1 |
| 1930 | Unique Length-3 Palindromic Subsequences | Medium | Bit Manipulation, Hash Table, String +1 |
| 1947 | Maximum Compatibility Score Sum | Medium | Bit Manipulation, Array, Dynamic Programming +2 |
| 1986 | Minimum Number of Work Sessions to Finish the Tasks | Medium | Bit Manipulation, Array, Dynamic Programming +2 |
| 2002 | Maximum Product of the Length of Two Palindromic Subsequences | Medium | Bit Manipulation, String, Dynamic Programming +2 |
| 2044 | Count Number of Maximum Bitwise-OR Subsets | Medium | Bit Manipulation, Array, Backtracking +1 |
| 2128 | Remove All Ones With Row and Column FlipsPremium | Medium | Bit Manipulation, Array, Math +1 |
| 2135 | Count Words Obtained After Adding a Letter | Medium | Bit Manipulation, Array, Hash Table +2 |
| 2152 | Minimum Number of Lines to Cover PointsPremium | Medium | Bit Manipulation, Geometry, Array +5 |
| 2174 | Remove All Ones With Row and Column Flips IIPremium | Medium | Bit Manipulation, Breadth-First Search, Array +1 |
| 2184 | Number of Ways to Build Sturdy Brick WallPremium | Medium | Bit Manipulation, Array, Dynamic Programming +1 |
| 2212 | Maximum Points in an Archery Competition | Medium | Bit Manipulation, Array, Backtracking +1 |
| 2275 | Largest Combination With Bitwise AND Greater Than Zero | Medium | Bit Manipulation, Array, Hash Table +1 |
| 2305 | Fair Distribution of Cookies | Medium | Bit Manipulation, Array, Dynamic Programming +2 |
| 2317 | Maximum XOR After Operations | Medium | Bit Manipulation, Array, Math |
| 2397 | Maximum Rows Covered by Columns | Medium | Bit Manipulation, Array, Backtracking +2 |
| 2401 | Longest Nice Subarray | Medium | Bit Manipulation, Array, Sliding Window |
| 2411 | Smallest Subarrays With Maximum Bitwise OR | Medium | Bit Manipulation, Array, Binary Search +1 |
| 2419 | Longest Subarray With Maximum Bitwise AND | Medium | Bit Manipulation, Brainteaser, Array |
| 2425 | Bitwise XOR of All Pairings | Medium | Bit Manipulation, Brainteaser, Array |
| 2429 | Minimize XOR | Medium | Greedy, Bit Manipulation |
| 2433 | Find The Original Array of Prefix Xor | Medium | Bit Manipulation, Array |
| 2438 | Range Product Queries of Powers | Medium | Bit Manipulation, Array, Prefix Sum |
| 2505 | Bitwise OR of All Subsequence SumsPremium | Medium | Bit Manipulation, Brainteaser, Array +2 |
| 2527 | Find Xor-Beauty of Array | Medium | Bit Manipulation, Array, Math |
| 2546 | Apply Bitwise Operations to Make Strings Equal | Medium | Bit Manipulation, String |
| 2564 | Substring XOR Queries | Medium | Bit Manipulation, Array, Hash Table +1 |
| 2568 | Minimum Impossible OR | Medium | Bit Manipulation, Brainteaser, Array |
| 2571 | Minimum Operations to Reduce an Integer to 0 | Medium | Greedy, Bit Manipulation, Dynamic Programming |
| 2572 | Count the Number of Square-Free Subsets | Medium | Bit Manipulation, Array, Math +2 |
| 2588 | Count the Number of Beautiful Subarrays | Medium | Bit Manipulation, Array, Hash Table +1 |
| 2657 | Find the Prefix Common Array of Two Arrays | Medium | Bit Manipulation, Array, Hash Table |
| 2680 | Maximum OR | Medium | Greedy, Bit Manipulation, Array +1 |
| 2683 | Neighboring Bitwise XOR | Medium | Bit Manipulation, Array |
| 2708 | Maximum Strength of a Group | Medium | Greedy, Bit Manipulation, Array +4 |
| 2741 | Special Permutations | Medium | Bit Manipulation, Array, Dynamic Programming +1 |
| 2749 | Minimum Operations to Make the Integer Zero | Medium | Bit Manipulation, Brainteaser, Enumeration |
| 2802 | Find The K-th Lucky NumberPremium | Medium | Bit Manipulation, Math, String |
| 2857 | Count Pairs of Points With Distance k | Medium | Bit Manipulation, Array, Hash Table |
| 2871 | Split Array Into Maximum Number of Subarrays | Medium | Greedy, Bit Manipulation, Array |
| 2939 | Maximum Xor Product | Medium | Greedy, Bit Manipulation, Math |
| 2992 | Number of Self-Divisible PermutationsPremium | Medium | Bit Manipulation, Array, Math +4 |
| 2997 | Minimum Number of Operations to Make Array XOR Equal to K | Medium | Bit Manipulation, Array |
Hard (58)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 691 | Stickers to Spell Word | Hard | Bit Manipulation, Memoization, Array +5 |
| 411 | Minimum Unique Word AbbreviationPremium | Hard | Bit Manipulation, Array, String +1 |
| 465 | Optimal Account BalancingPremium | Hard | Bit Manipulation, Array, Dynamic Programming +2 |
| 782 | Transform to Chessboard | Hard | Bit Manipulation, Array, Math +1 |
| 805 | Split Array With Same Average | Hard | Bit Manipulation, Array, Math +2 |
| 810 | Chalkboard XOR Game | Hard | Bit Manipulation, Brainteaser, Array +2 |
| 847 | Shortest Path Visiting All Nodes | Hard | Bit Manipulation, Breadth-First Search, Graph +2 |
| 864 | Shortest Path to Get All Keys | Hard | Bit Manipulation, Breadth-First Search, Array +1 |
| 943 | Find the Shortest Superstring | Hard | Bit Manipulation, Array, String +2 |
| 980 | Unique Paths III | Hard | Bit Manipulation, Array, Backtracking +1 |
| 982 | Triples with Bitwise AND Equal To Zero | Hard | Bit Manipulation, Array, Hash Table |
| 995 | Minimum Number of K Consecutive Bit Flips | Hard | Bit Manipulation, Queue, Array +2 |
| 996 | Number of Squareful Arrays | Hard | Bit Manipulation, Array, Hash Table +4 |
| 1125 | Smallest Sufficient Team | Hard | Bit Manipulation, Array, Dynamic Programming +1 |
| 1178 | Number of Valid Words for Each Puzzle | Hard | Bit Manipulation, Trie, Array +2 |
| 1255 | Maximum Score Words Formed by Letters | Hard | Bit Manipulation, Array, Hash Table +5 |
| 1284 | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix | Hard | Bit Manipulation, Breadth-First Search, Array +2 |
| 1349 | Maximum Students Taking Exam | Hard | Bit Manipulation, Array, Dynamic Programming +2 |
| 1434 | Number of Ways to Wear Different Hats to Each Other | Hard | Bit Manipulation, Array, Dynamic Programming +1 |
| 1483 | Kth Ancestor of a Tree Node | Hard | Bit Manipulation, Tree, Depth-First Search +4 |
| 1494 | Parallel Courses II | Hard | Bit Manipulation, Graph, Dynamic Programming +1 |
| 1521 | Find a Value of a Mysterious Function Closest to Target | Hard | Bit Manipulation, Segment Tree, Array +1 |
| 1542 | Find Longest Awesome Substring | Hard | Bit Manipulation, Hash Table, String |
| 1595 | Minimum Cost to Connect Two Groups of Points | Hard | Bit Manipulation, Array, Dynamic Programming +2 |
| 1601 | Maximum Number of Achievable Transfer Requests | Hard | Bit Manipulation, Array, Backtracking +1 |
| 1611 | Minimum One Bit Operations to Make Integers Zero | Hard | Bit Manipulation, Memoization, Dynamic Programming |
| 1617 | Count Subtrees With Max Distance Between Cities | Hard | Bit Manipulation, Tree, Dynamic Programming +2 |
| 1655 | Distribute Repeating Integers | Hard | Bit Manipulation, Array, Dynamic Programming +2 |
| 1659 | Maximize Grid Happiness | Hard | Bit Manipulation, Memoization, Dynamic Programming +1 |
| 1681 | Minimum Incompatibility | Hard | Bit Manipulation, Array, Dynamic Programming +1 |
| 1707 | Maximum XOR With an Element From Array | Hard | Bit Manipulation, Trie, Array |
| 1723 | Find Minimum Time to Finish All Jobs | Hard | Bit Manipulation, Array, Dynamic Programming +2 |
| 1755 | Closest Subsequence Sum | Hard | Bit Manipulation, Array, Two Pointers +3 |
| 1787 | Make the XOR of All Segments Equal to Zero | Hard | Bit Manipulation, Array, Dynamic Programming |
| 1799 | Maximize Score After N Operations | Hard | Bit Manipulation, Array, Math +4 |
| 1803 | Count Pairs With XOR in a Range | Hard | Bit Manipulation, Trie, Array |
| 1815 | Maximum Number of Groups Getting Fresh Donuts | Hard | Bit Manipulation, Memoization, Array +2 |
| 1835 | Find XOR Sum of All Pairs Bitwise AND | Hard | Bit Manipulation, Array, Math |
| 1879 | Minimum XOR Sum of Two Arrays | Hard | Bit Manipulation, Array, Dynamic Programming +1 |
| 1938 | Maximum Genetic Difference Query | Hard | Bit Manipulation, Depth-First Search, Trie +2 |
| 1994 | The Number of Good Subsets | Hard | Bit Manipulation, Array, Hash Table +5 |
| 2035 | Partition Array Into Two Arrays to Minimize Sum Difference | Hard | Bit Manipulation, Array, Two Pointers +4 |
| 2151 | Maximum Good People Based on Statements | Hard | Bit Manipulation, Array, Backtracking +1 |
| 2157 | Groups of Strings | Hard | Bit Manipulation, Union Find, String |
| 2172 | Maximum AND Sum of Array | Hard | Bit Manipulation, Array, Dynamic Programming +1 |
| 2247 | Maximum Cost of Trip With K HighwaysPremium | Hard | Bit Manipulation, Graph, Dynamic Programming +1 |
| 2306 | Naming a Company | Hard | Bit Manipulation, Array, Hash Table +2 |
| 2322 | Minimum Score After Removals on a Tree | Hard | Bit Manipulation, Tree, Depth-First Search +1 |
| 2354 | Number of Excellent Pairs | Hard | Bit Manipulation, Array, Hash Table +1 |
| 2403 | Minimum Time to Kill All MonstersPremium | Hard | Bit Manipulation, Array, Dynamic Programming +1 |
| 2732 | Find a Good Subset of the Matrix | Hard | Bit Manipulation, Array, Hash Table +1 |
| 2791 | Count Paths That Can Form a Palindrome in a Tree | Hard | Bit Manipulation, Tree, Depth-First Search +2 |
| 2835 | Minimum Operations to Form Subsequence With Target Sum | Hard | Greedy, Bit Manipulation, Array |
| 2836 | Maximize Value of Function in a Ball Passing Game | Hard | Bit Manipulation, Array, Dynamic Programming |
| 2897 | Apply Operations on Array to Maximize Sum of Squares | Hard | Greedy, Bit Manipulation, Array +1 |
| 2920 | Maximum Points After Collecting Coins From All Nodes | Hard | Bit Manipulation, Tree, Depth-First Search +3 |
| 2935 | Maximum Strong Pair XOR II | Hard | Bit Manipulation, Trie, Array +2 |
| 2959 | Number of Possible Sets of Closing Branches | Hard | Bit Manipulation, Graph, Enumeration +2 |
Related patterns
Problems sit in more than one pattern more often than not, and the overlap is where the interesting follow-up questions live.
Bit Manipulation pattern FAQ
What is the bit manipulation pattern?
Bit manipulation problems reduce to a handful of identities that are worth knowing cold. XOR is its own inverse and is commutative, so xor-ing an entire array cancels every value that appears twice and leaves the one that does not — no hash map, no extra space.
How many LeetCode problems use the bit manipulation pattern?
This page lists 194 LeetCode problems that the bit manipulation pattern applies to: 40 Easy, 96 Medium and 58 Hard. 173 of them carry a complete Python solution with complexity analysis.
What is the time complexity of the bit manipulation pattern?
O(n) for a scan, O(2ⁿ) for subset enumeration time and O(1) space. The XOR cancellation scan is one pass with a single accumulator: linear time, constant space, no hash map. Counting set bits with x & (x − 1) runs once per set bit rather than once per bit position, so it is O(popcount) instead of O(word size). Bitmask enumeration is O(2ⁿ) by definition and bitmask dynamic programming is O(2ⁿ·n), which is why these problems cap n at around twenty.
When should I use the bit manipulation pattern in an interview?
Every element appears a fixed number of times except one — XOR or per-bit counting finds it. The problem is about set bits, powers of two, or a specific bit position.
Which bit manipulation problem should I start with?
LeetCode 67. Add Binary is the lowest-numbered Easy problem on this page, which makes it the usual starting point: the technique is visible without the problem's own complications getting in the way.
What patterns are related to bit manipulation?
Dynamic Programming, Hash Map, Backtracking, Math and Number Theory. Problems frequently sit in more than one of these, and the overlap is where the interesting follow-up questions come from.
More ways in: all 22 patterns, the curated study lists, or the full problem list.
Meet the bit manipulation problem you did not practise
Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.