Skip to content

Bit Manipulation Problems

220 Bit Manipulation LeetCode problems · Browse tasks by difficulty and choose your next practice problem.

Learn the coding interview patterns behind these problems.

Start with these

All Bit Manipulation problems

29 Divide Two Integers Medium67 Add Binary Easy78 Subsets Medium89 Gray Code Medium90 Subsets II Medium136 Single Number Easy137 Single Number II Medium187 Repeated DNA Sequences Medium190 Reverse Bits Easy191 Number of 1 Bits Easy201 Bitwise AND of Numbers Range Medium222 Count Complete Tree Nodes Easy231 Power of Two Easy260 Single Number III Medium268 Missing Number Easy287 Find the Duplicate Number Medium318 Maximum Product of Word Lengths Medium338 Counting Bits Easy342 Power of Four Easy371 Sum of Two Integers Medium389 Find the Difference Easy393 UTF-8 Validation Medium397 Integer Replacement Medium401 Binary Watch Easy405 Convert a Number to Hexadecimal Easy421 Maximum XOR of Two Numbers in an Array Medium461 Hamming Distance Easy464 Can I Win Medium473 Matchsticks to Square Medium476 Number Complement Easy477 Total Hamming Distance Medium491 Non-decreasing Subsequences Medium526 Beautiful Arrangement Medium638 Shopping Offers Medium645 Set Mismatch Easy672 Bulb Switcher II Medium691 Stickers to Spell Word Hard693 Binary Number with Alternating Bits Easy698 Partition to K Equal Sum Subsets Medium756 Pyramid Transition Matrix Medium762 Prime Number of Set Bits in Binary Representation Easy779 K-th Symbol in Grammar Medium782 Transform to Chessboard Hard784 Letter Case Permutation Medium805 Split Array With Same Average Hard810 Chalkboard XOR Game Hard832 Flipping an Image Easy847 Shortest Path Visiting All Nodes Hard861 Score After Flipping Matrix Medium864 Shortest Path to Get All Keys Hard868 Binary Gap Easy898 Bitwise ORs of Subarrays Medium943 Find the Shortest Superstring Hard957 Prison Cells After N Days Medium980 Unique Paths III Hard982 Triples with Bitwise AND Equal To Zero Hard995 Minimum Number of K Consecutive Bit Flips Hard996 Number of Squareful Arrays Hard1009 Complement of Base 10 Integer Easy1016 Binary String With Substrings Representing 1 To N Medium1018 Binary Prefix Divisible By 5 Easy1125 Smallest Sufficient Team Hard1177 Can Make Palindrome from Substring Medium1178 Number of Valid Words for Each Puzzle Hard1238 Circular Permutation in Binary Representation Medium1239 Maximum Length of a Concatenated String with Unique Characters Medium1255 Maximum Score Words Formed by Letters Hard1284 Minimum Number of Flips to Convert Binary Matrix to Zero Matrix Hard1310 XOR Queries of a Subarray Medium1318 Minimum Flips to Make a OR b Equal to c Medium1342 Number of Steps to Reduce a Number to Zero Easy1349 Maximum Students Taking Exam Hard1356 Sort Integers by The Number of 1 Bits Easy1371 Find the Longest Substring Containing Vowels in Even Counts Medium1386 Cinema Seat Allocation Medium1404 Number of Steps to Reduce a Number in Binary Representation to One Medium1434 Number of Ways to Wear Different Hats to Each Other Hard1442 Count Triplets That Can Form Two Arrays of Equal XOR Medium1457 Pseudo-Palindromic Paths in a Binary Tree Medium1461 Check If a String Contains All Binary Codes of Size K Medium1486 XOR Operation in an Array Easy1494 Parallel Courses II Hard1521 Find a Value of a Mysterious Function Closest to Target Hard1525 Number of Good Ways to Split a String Medium1542 Find Longest Awesome Substring Hard1558 Minimum Numbers of Function Calls to Make Target Array Medium1595 Minimum Cost to Connect Two Groups of Points Hard1601 Maximum Number of Achievable Transfer Requests Hard1611 Minimum One Bit Operations to Make Integers Zero Hard1617 Count Subtrees With Max Distance Between Cities Hard1655 Distribute Repeating Integers Hard1659 Maximize Grid Happiness Hard1680 Concatenation of Consecutive Binary Numbers Medium1681 Minimum Incompatibility Hard1684 Count the Number of Consistent Strings Easy1707 Maximum XOR With an Element From Array Hard1720 Decode XORed Array Easy1723 Find Minimum Time to Finish All Jobs Hard1734 Decode XORed Permutation Medium1738 Find Kth Largest XOR Coordinate Value Medium1755 Closest Subsequence Sum Hard1763 Longest Nice Substring Easy1787 Make the XOR of All Segments Equal to Zero Hard1799 Maximize Score After N Operations Hard1803 Count Pairs With XOR in a Range Hard1815 Maximum Number of Groups Getting Fresh Donuts Hard1829 Maximum XOR for Each Query Medium1835 Find XOR Sum of All Pairs Bitwise AND Hard1863 Sum of All Subset XOR Totals Easy1879 Minimum XOR Sum of Two Arrays Hard1915 Number of Wonderful Substrings Medium1930 Unique Length-3 Palindromic Subsequences Medium1938 Maximum Genetic Difference Query Hard1947 Maximum Compatibility Score Sum Medium1986 Minimum Number of Work Sessions to Finish the Tasks Medium1994 The Number of Good Subsets Hard2002 Maximum Product of the Length of Two Palindromic Subsequences Medium2032 Two Out of Three Easy2035 Partition Array Into Two Arrays to Minimize Sum Difference Hard2044 Count Number of Maximum Bitwise-OR Subsets Medium2135 Count Words Obtained After Adding a Letter Medium2151 Maximum Good People Based on Statements Hard2157 Groups of Strings Hard2172 Maximum AND Sum of Array Hard2206 Divide Array Into Equal Pairs Easy2212 Maximum Points in an Archery Competition Medium2220 Minimum Bit Flips to Convert Number Easy2275 Largest Combination With Bitwise AND Greater Than Zero Medium2305 Fair Distribution of Cookies Medium2306 Naming a Company Hard2317 Maximum XOR After Operations Medium2322 Minimum Score After Removals on a Tree Hard2351 First Letter to Appear Twice Easy2354 Number of Excellent Pairs Hard2397 Maximum Rows Covered by Columns Medium2401 Longest Nice Subarray Medium2411 Smallest Subarrays With Maximum Bitwise OR Medium2419 Longest Subarray With Maximum Bitwise AND Medium2425 Bitwise XOR of All Pairings Medium2429 Minimize XOR Medium2433 Find The Original Array of Prefix Xor Medium2438 Range Product Queries of Powers Medium2506 Count Pairs Of Similar Strings Easy2527 Find Xor-Beauty of Array Medium2546 Apply Bitwise Operations to Make Strings Equal Medium2564 Substring XOR Queries Medium2568 Minimum Impossible OR Medium2571 Minimum Operations to Reduce an Integer to 0 Medium2572 Count the Number of Square-Free Subsets Medium2588 Count the Number of Beautiful Subarrays Medium2595 Number of Even and Odd Bits Easy2657 Find the Prefix Common Array of Two Arrays Medium2680 Maximum OR Medium2683 Neighboring Bitwise XOR Medium2708 Maximum Strength of a Group Medium2732 Find a Good Subset of the Matrix Hard2741 Special Permutations Medium2749 Minimum Operations to Make the Integer Zero Medium2791 Count Paths That Can Form a Palindrome in a Tree Hard2835 Minimum Operations to Form Subsequence With Target Sum Hard2836 Maximize Value of Function in a Ball Passing Game Hard2857 Count Pairs of Points With Distance k Medium2859 Sum of Values at Indices With K Set Bits Easy2869 Minimum Operations to Collect Elements Easy2871 Split Array Into Maximum Number of Subarrays Medium2897 Apply Operations on Array to Maximize Sum of Squares Hard2917 Find the K-or of an Array Easy2920 Maximum Points After Collecting Coins From All Nodes Hard2932 Maximum Strong Pair XOR I Easy2935 Maximum Strong Pair XOR II Hard2939 Maximum Xor Product Medium2959 Number of Possible Sets of Closing Branches Hard2980 Check if Bitwise OR Has Trailing Zeros Easy2997 Minimum Number of Operations to Make Array XOR Equal to K Medium3003 Maximize the Number of Partitions After Operations Hard3007 Maximum Number That Sum of the Prices Is Less Than or Equal to K Medium3011 Find if Array Can Be Sorted Medium3022 Minimize OR of Remaining Elements Using Operations Hard3068 Find the Maximum Sum of Node Values Hard3095 Shortest Subarray With OR at Least K I Easy3097 Shortest Subarray With OR at Least K II Medium3108 Minimum Cost Walk in Weighted Graph Hard3116 Kth Smallest Amount With Single Denomination Combination Hard3117 Minimum Sum of Values by Dividing Array Hard3133 Minimum Array End Medium3145 Find Products of Elements of Big Array Hard3149 Find the Minimum Cost Array Permutation Hard3154 Find Number of Ways to Reach the K-th Stair Hard3158 Find the XOR of Numbers Which Appear Twice Easy3171 Find Subarray With Bitwise OR Closest to K Hard3181 Maximum Total Reward Using Operations II Hard3191 Minimum Operations to Make Binary Array Elements Equal to One I Medium3209 Number of Subarrays With AND Value of K Hard3211 Generate Binary Strings Without Adjacent Zeros Medium3226 Number of Bit Changes to Make Two Integers Equal Easy3276 Select Cells in Grid With Maximum Score Hard3283 Maximum Number of Moves to Kill All Pawns Hard3287 Find the Maximum Sequence Value of Array Hard3304 Find the K-th Character in String Game I Easy3307 Find the K-th Character in String Game II Hard3309 Maximum Possible Number by Binary Concatenation Medium3314 Construct the Minimum Bitwise Array I Easy3315 Construct the Minimum Bitwise Array II Medium3370 Smallest Number With All Set Bits Easy3376 Minimum Time to Break Locks I Medium3393 Count Paths With the Given XOR Value Medium3435 Frequencies of Shortest Supersequences Hard3444 Minimum Increments for Target Multiples in an Array Hard3495 Minimum Operations to Make Array Elements Zero Hard3513 Number of Unique XOR Triplets I Medium3514 Number of Unique XOR Triplets II Medium3530 Maximum Profit from Valid Topological Order in DAG Hard3533 Concatenated Divisibility Hard3539 Find Sum of Array Product of Magical Sequences Hard3566 Partition Array into Two Equal Product Subsets Medium3568 Minimum Moves to Clean the Classroom Medium3575 Maximum Good Subtree Score Hard3594 Minimum Time to Transport All Individuals Hard3599 Partition Array to Minimize XOR Medium3615 Longest Palindromic Path in Graph Hard