method
Bit Manipulation — animated LeetCode walkthroughs
LeetCode problems solved with Bit Manipulation. Browse the complete tag, then watch the algorithm move — step-by-step animation, Python and Go.
296 problems · 263 animated · 33 locked
Full Bitmask index
- 29Divide Two IntegersWatch
- 67Add BinaryWatch
- 78SubsetsWatch
- 89Gray CodeWatch
- 90Subsets IIWatch
- 136Single NumberWatch
- 137Single Number IIWatch
- 187Repeated DNA SequencesWatch
- 190Reverse BitsWatch
- 191Number of 1 BitsWatch
- 201Bitwise AND of Numbers RangeWatch
- 222Count Complete Tree NodesWatch
- 231Power of TwoWatch
- 260Single Number IIIWatch
- 266Palindrome PermutationLocked
- 268Missing NumberWatch
- 287Find the Duplicate NumberWatch
- 318Maximum Product of Word LengthsWatch
- 320Generalized AbbreviationLocked
- 338Counting BitsWatch
- 342Power of FourWatch
- 351Android Unlock PatternsLocked
- 371Sum of Two IntegersWatch
- 389Find the DifferenceWatch
- 393UTF-8 ValidationWatch
- 397Integer ReplacementWatch
- 401Binary WatchWatch
- 405Convert a Number to HexadecimalWatch
- 411Minimum Unique Word AbbreviationLocked
- 421Maximum XOR of Two Numbers in an ArrayWatch
- 461Hamming DistanceWatch
- 464Can I WinWatch
- 465Optimal Account BalancingLocked
- 473Matchsticks to SquareWatch
- 476Number ComplementWatch
- 477Total Hamming DistanceWatch
- 491Non-decreasing SubsequencesWatch
- 526Beautiful ArrangementWatch
- 638Shopping OffersWatch
- 645Set MismatchWatch
- 672Bulb Switcher IIWatch
- 691Stickers to Spell WordWatch
- 693Binary Number with Alternating BitsWatch
- 698Partition to K Equal Sum SubsetsWatch
- 751IP to CIDRLocked
- 756Pyramid Transition MatrixWatch
- 762Prime Number of Set Bits in Binary RepresentationWatch
- 779K-th Symbol in GrammarWatch
- 782Transform to ChessboardWatch
- 784Letter Case PermutationWatch
- 805Split Array With Same AverageWatch
- 810Chalkboard XOR GameWatch
- 832Flipping an ImageWatch
- 847Shortest Path Visiting All NodesWatch
- 861Score After Flipping MatrixWatch
- 864Shortest Path to Get All KeysWatch
- 868Binary GapWatch
- 898Bitwise ORs of SubarraysWatch
- 943Find the Shortest SuperstringWatch
- 957Prison Cells After N DaysWatch
- 980Unique Paths IIIWatch
- 982Triples with Bitwise AND Equal To ZeroWatch
- 995Minimum Number of K Consecutive Bit FlipsWatch
- 996Number of Squareful ArraysWatch
- 1009Complement of Base 10 IntegerWatch
- 1016Binary String With Substrings Representing 1 To NWatch
- 1018Binary Prefix Divisible By 5Watch
- 1066Campus Bikes IILocked
- 1125Smallest Sufficient TeamWatch
- 1177Can Make Palindrome from SubstringWatch
- 1178Number of Valid Words for Each PuzzleWatch
- 1238Circular Permutation in Binary RepresentationWatch
- 1239Maximum Length of a Concatenated String with Unique CharactersWatch
- 1255Maximum Score Words Formed by LettersWatch
- 1256Encode NumberLocked
- 1284Minimum Number of Flips to Convert Binary Matrix to Zero MatrixWatch
- 1310XOR Queries of a SubarrayWatch
- 1318Minimum Flips to Make a OR b Equal to cWatch
- 1342Number of Steps to Reduce a Number to ZeroWatch
- 1349Maximum Students Taking ExamWatch
- 1356Sort Integers by The Number of 1 BitsWatch
- 1371Find the Longest Substring Containing Vowels in Even CountsWatch
- 1386Cinema Seat AllocationWatch
- 1404Number of Steps to Reduce a Number in Binary Representation to OneWatch
- 1434Number of Ways to Wear Different Hats to Each OtherWatch
- 1442Count Triplets That Can Form Two Arrays of Equal XORWatch
- 1457Pseudo-Palindromic Paths in a Binary TreeWatch
- 1461Check If a String Contains All Binary Codes of Size KWatch
- 1483Kth Ancestor of a Tree NodeWatch
- 1486XOR Operation in an ArrayWatch
- 1494Parallel Courses IIWatch
- 1506Find Root of N-Ary TreeLocked
- 1521Find a Value of a Mysterious Function Closest to TargetWatch
- 1525Number of Good Ways to Split a StringWatch
- 1542Find Longest Awesome SubstringWatch
- 1558Minimum Numbers of Function Calls to Make Target ArrayWatch
- 1595Minimum Cost to Connect Two Groups of PointsWatch
- 1601Maximum Number of Achievable Transfer RequestsWatch
- 1611Minimum One Bit Operations to Make Integers ZeroWatch
- 1617Count Subtrees With Max Distance Between CitiesWatch
- 1655Distribute Repeating IntegersWatch
- 1659Maximize Grid HappinessWatch
- 1680Concatenation of Consecutive Binary NumbersWatch
- 1681Minimum IncompatibilityWatch
- 1684Count the Number of Consistent StringsWatch
- 1707Maximum XOR With an Element From ArrayWatch
- 1720Decode XORed ArrayWatch
- 1723Find Minimum Time to Finish All JobsWatch
- 1734Decode XORed PermutationWatch
- 1738Find Kth Largest XOR Coordinate ValueWatch
- 1755Closest Subsequence SumWatch
- 1763Longest Nice SubstringWatch
- 1787Make the XOR of All Segments Equal to ZeroWatch
- 1799Maximize Score After N OperationsWatch
- 1803Count Pairs With XOR in a RangeWatch
- 1815Maximum Number of Groups Getting Fresh DonutsWatch
- 1829Maximum XOR for Each QueryWatch
- 1835Find XOR Sum of All Pairs Bitwise ANDWatch
- 1863Sum of All Subset XOR TotalsWatch
- 1879Minimum XOR Sum of Two ArraysWatch
- 1908Game of NimLocked
- 1915Number of Wonderful SubstringsWatch
- 1930Unique Length-3 Palindromic SubsequencesWatch
- 1938Maximum Genetic Difference QueryWatch
- 1947Maximum Compatibility Score SumWatch
- 1986Minimum Number of Work Sessions to Finish the TasksWatch
- 1994The Number of Good SubsetsWatch
- 2002Maximum Product of the Length of Two Palindromic SubsequencesWatch
- 2032Two Out of ThreeWatch
- 2035Partition Array Into Two Arrays to Minimize Sum DifferenceWatch
- 2044Count Number of Maximum Bitwise-OR SubsetsWatch
- 2128Remove All Ones With Row and Column FlipsLocked
- 2135Count Words Obtained After Adding a LetterWatch
- 2151Maximum Good People Based on StatementsWatch
- 2152Minimum Number of Lines to Cover PointsLocked
- 2157Groups of StringsWatch
- 2172Maximum AND Sum of ArrayWatch
- 2174Remove All Ones With Row and Column Flips IILocked
- 2184Number of Ways to Build Sturdy Brick WallLocked
- 2206Divide Array Into Equal PairsWatch
- 2212Maximum Points in an Archery CompetitionWatch
- 2220Minimum Bit Flips to Convert NumberWatch
- 2247Maximum Cost of Trip With K HighwaysLocked
- 2275Largest Combination With Bitwise AND Greater Than ZeroWatch
- 2305Fair Distribution of CookiesWatch
- 2306Naming a CompanyWatch
- 2317Maximum XOR After Operations Watch
- 2322Minimum Score After Removals on a TreeWatch
- 2351First Letter to Appear TwiceWatch
- 2354Number of Excellent PairsWatch
- 2397Maximum Rows Covered by ColumnsWatch
- 2401Longest Nice SubarrayWatch
- 2403Minimum Time to Kill All MonstersLocked
- 2411Smallest Subarrays With Maximum Bitwise ORWatch
- 2419Longest Subarray With Maximum Bitwise ANDWatch
- 2425Bitwise XOR of All PairingsWatch
- 2429Minimize XORWatch
- 2433Find The Original Array of Prefix XorWatch
- 2438Range Product Queries of PowersWatch
- 2505Bitwise OR of All Subsequence SumsLocked
- 2506Count Pairs Of Similar StringsWatch
- 2527Find Xor-Beauty of ArrayWatch
- 2546Apply Bitwise Operations to Make Strings EqualWatch
- 2564Substring XOR QueriesWatch
- 2568Minimum Impossible ORWatch
- 2571Minimum Operations to Reduce an Integer to 0Watch
- 2572Count the Number of Square-Free SubsetsWatch
- 2588Count the Number of Beautiful SubarraysWatch
- 2595Number of Even and Odd BitsWatch
- 2657Find the Prefix Common Array of Two ArraysWatch
- 2680Maximum ORWatch
- 2683Neighboring Bitwise XORWatch
- 2708Maximum Strength of a GroupWatch
- 2732Find a Good Subset of the MatrixWatch
- 2741Special PermutationsWatch
- 2749Minimum Operations to Make the Integer ZeroWatch
- 2791Count Paths That Can Form a Palindrome in a TreeWatch
- 2802Find The K-th Lucky NumberLocked
- 2835Minimum Operations to Form Subsequence With Target SumWatch
- 2836Maximize Value of Function in a Ball Passing GameWatch
- 2846Minimum Edge Weight Equilibrium Queries in a TreeWatch
- 2850Minimum Moves to Spread Stones Over GridWatch
- 2857Count Pairs of Points With Distance kWatch
- 2859Sum of Values at Indices With K Set BitsWatch
- 2869Minimum Operations to Collect ElementsWatch
- 2871Split Array Into Maximum Number of SubarraysWatch
- 2897Apply Operations on Array to Maximize Sum of SquaresWatch
- 2917Find the K-or of an ArrayWatch
- 2920Maximum Points After Collecting Coins From All NodesWatch
- 2932Maximum Strong Pair XOR IWatch
- 2935Maximum Strong Pair XOR IIWatch
- 2939Maximum Xor ProductWatch
- 2959Number of Possible Sets of Closing BranchesWatch
- 2980Check if Bitwise OR Has Trailing ZerosWatch
- 2992Number of Self-Divisible PermutationsLocked
- 2997Minimum Number of Operations to Make Array XOR Equal to KWatch
- 3003Maximize the Number of Partitions After OperationsWatch
- 3007Maximum Number That Sum of the Prices Is Less Than or Equal to KWatch
- 3011Find if Array Can Be SortedWatch
- 3022Minimize OR of Remaining Elements Using OperationsWatch
- 3064Guess the Number Using Bitwise Questions ILocked
- 3068Find the Maximum Sum of Node ValuesWatch
- 3094Guess the Number Using Bitwise Questions IILocked
- 3095Shortest Subarray With OR at Least K IWatch
- 3097Shortest Subarray With OR at Least K IIWatch
- 3108Minimum Cost Walk in Weighted GraphWatch
- 3116Kth Smallest Amount With Single Denomination CombinationWatch
- 3117Minimum Sum of Values by Dividing ArrayWatch
- 3133Minimum Array EndWatch
- 3141Maximum Hamming DistancesLocked
- 3145Find Products of Elements of Big ArrayWatch
- 3149Find the Minimum Cost Array PermutationWatch
- 3154Find Number of Ways to Reach the K-th StairWatch
- 3158Find the XOR of Numbers Which Appear TwiceWatch
- 3171Find Subarray With Bitwise OR Closest to KWatch
- 3173Bitwise OR of Adjacent ElementsLocked
- 3180Maximum Total Reward Using Operations IWatch
- 3181Maximum Total Reward Using Operations IIWatch
- 3191Minimum Operations to Make Binary Array Elements Equal to One IWatch
- 3199Count Triplets with Even XOR Set Bits ILocked
- 3209Number of Subarrays With AND Value of KWatch
- 3211Generate Binary Strings Without Adjacent ZerosWatch
- 3215Count Triplets with Even XOR Set Bits IILocked
- 3226Number of Bit Changes to Make Two Integers EqualWatch
- 3276Select Cells in Grid With Maximum ScoreWatch
- 3283Maximum Number of Moves to Kill All PawnsWatch
- 3287Find the Maximum Sequence Value of ArrayWatch
- 3304Find the K-th Character in String Game IWatch
- 3307Find the K-th Character in String Game IIWatch
- 3309Maximum Possible Number by Binary ConcatenationWatch
- 3314Construct the Minimum Bitwise Array IWatch
- 3315Construct the Minimum Bitwise Array IIWatch
- 3344Maximum Sized ArrayLocked
- 3370Smallest Number With All Set BitsWatch
- 3376Minimum Time to Break Locks IWatch
- 3393Count Paths With the Given XOR ValueWatch
- 3435Frequencies of Shortest SupersequencesWatch
- 3444Minimum Increments for Target Multiples in an ArrayWatch
- 3495Minimum Operations to Make Array Elements ZeroWatch
- 3513Number of Unique XOR Triplets IWatch
- 3514Number of Unique XOR Triplets IIWatch
- 3526Range XOR Queries with Subarray ReversalsLocked
- 3530Maximum Profit from Valid Topological Order in DAGWatch
- 3533Concatenated DivisibilityWatch
- 3534Path Existence Queries in a Graph IIWatch
- 3539Find Sum of Array Product of Magical SequencesWatch
- 3553Minimum Weighted Subgraph With the Required Paths IIWatch
- 3559Number of Ways to Assign Edge Weights IIWatch
- 3566Partition Array into Two Equal Product SubsetsWatch
- 3568Minimum Moves to Clean the ClassroomWatch
- 3575Maximum Good Subtree ScoreWatch
- 3585Find Weighted Median Node in TreeWatch
- 3594Minimum Time to Transport All IndividualsWatch
- 3595Once TwiceLocked
- 3599Partition Array to Minimize XORWatch
- 3615Longest Palindromic Path in GraphWatch
- 3621Number of Integers With Popcount-Depth Equal to K IWatch
- 3630Partition Array for Maximum XOR and ANDWatch
- 3632Subarrays with XOR at Least KLocked
- 3644Maximum K to Sort a PermutationWatch
- 3646Next Special Palindrome NumberWatch
- 3670Maximum Product of Two Integers With No Common BitsWatch
- 3674Minimum Operations to Equalize ArrayWatch
- 3677Count Binary Palindromic NumbersWatch
- 3681Maximum XOR of SubsequencesWatch
- 3688Bitwise OR of Even Numbers in an ArrayWatch
- 3702Longest Subsequence With Non-Zero Bitwise XORWatch
- 3750Minimum Number of Flips to Reverse Binary StringWatch
- 3755Find Maximum Balanced XOR Subarray LengthWatch
- 3757Number of Effective SubsequencesWatch
- 3766Minimum Operations to Make Binary PalindromeWatch
- 3801Minimum Cost to Merge Sorted ListsWatch
- 3806Maximum Bitwise AND After Increment OperationsWatch
- 3811Number of Alternating XOR PartitionsWatch
- 3821Find Nth Smallest Integer With K One BitsWatch
- 3825Longest Strictly Increasing Subsequence With Non-Zero Bitwise ANDWatch
- 3827Count Monobit IntegersWatch
- 3841Palindromic Path Queries in a TreeWatch
- 3845Maximum Subarray XOR with Bounded RangeWatch
- 3849Maximum Bitwise XOR After RearrangementWatch
- 3858Minimum Bitwise OR From GridWatch
- 3877Minimum Removals to Achieve Target XORWatch
- 3878Count Good SubarraysWatch
- 3882Minimum XOR Path in a GridWatch
- 3910Count Connected Subgraphs with Even Node SumWatch
- 3950Exactly One Consecutive Set Bits PairWatch
- 3954Sum of Compatible Numbers in Range IWatch
- 3955Valid Binary Strings With Cost LimitWatch
- 3973Distinct Gate Paths to LCALocked
- 3990Create Grid With Exactly K Paths IILocked
- 4027Elevator Requests IIIWatch
- 4030Check ASCII PalindromicWatch
- 4033Valid K-Unique Subarrays IWatch
- 4036Lexicographically Largest String After Pair TransformationsWatch
- 4042Valid K-Unique Subarrays IILocked
- 4047Minimum Operations to Make XOR of All Elements ZeroLocked