Skip to content
LEETFLIX

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

  1. 29Divide Two IntegersWatch
  2. 67Add BinaryWatch
  3. 78SubsetsWatch
  4. 89Gray CodeWatch
  5. 90Subsets IIWatch
  6. 136Single NumberWatch
  7. 137Single Number IIWatch
  8. 187Repeated DNA SequencesWatch
  9. 190Reverse BitsWatch
  10. 191Number of 1 BitsWatch
  11. 201Bitwise AND of Numbers RangeWatch
  12. 222Count Complete Tree NodesWatch
  13. 231Power of TwoWatch
  14. 260Single Number IIIWatch
  15. 266Palindrome PermutationLocked
  16. 268Missing NumberWatch
  17. 287Find the Duplicate NumberWatch
  18. 318Maximum Product of Word LengthsWatch
  19. 320Generalized AbbreviationLocked
  20. 338Counting BitsWatch
  21. 342Power of FourWatch
  22. 351Android Unlock PatternsLocked
  23. 371Sum of Two IntegersWatch
  24. 389Find the DifferenceWatch
  25. 393UTF-8 ValidationWatch
  26. 397Integer ReplacementWatch
  27. 401Binary WatchWatch
  28. 405Convert a Number to HexadecimalWatch
  29. 411Minimum Unique Word AbbreviationLocked
  30. 421Maximum XOR of Two Numbers in an ArrayWatch
  31. 461Hamming DistanceWatch
  32. 464Can I WinWatch
  33. 465Optimal Account BalancingLocked
  34. 473Matchsticks to SquareWatch
  35. 476Number ComplementWatch
  36. 477Total Hamming DistanceWatch
  37. 491Non-decreasing SubsequencesWatch
  38. 526Beautiful ArrangementWatch
  39. 638Shopping OffersWatch
  40. 645Set MismatchWatch
  41. 672Bulb Switcher IIWatch
  42. 691Stickers to Spell WordWatch
  43. 693Binary Number with Alternating BitsWatch
  44. 698Partition to K Equal Sum SubsetsWatch
  45. 751IP to CIDRLocked
  46. 756Pyramid Transition MatrixWatch
  47. 762Prime Number of Set Bits in Binary RepresentationWatch
  48. 779K-th Symbol in GrammarWatch
  49. 782Transform to ChessboardWatch
  50. 784Letter Case PermutationWatch
  51. 805Split Array With Same AverageWatch
  52. 810Chalkboard XOR GameWatch
  53. 832Flipping an ImageWatch
  54. 847Shortest Path Visiting All NodesWatch
  55. 861Score After Flipping MatrixWatch
  56. 864Shortest Path to Get All KeysWatch
  57. 868Binary GapWatch
  58. 898Bitwise ORs of SubarraysWatch
  59. 943Find the Shortest SuperstringWatch
  60. 957Prison Cells After N DaysWatch
  61. 980Unique Paths IIIWatch
  62. 982Triples with Bitwise AND Equal To ZeroWatch
  63. 995Minimum Number of K Consecutive Bit FlipsWatch
  64. 996Number of Squareful ArraysWatch
  65. 1009Complement of Base 10 IntegerWatch
  66. 1016Binary String With Substrings Representing 1 To NWatch
  67. 1018Binary Prefix Divisible By 5Watch
  68. 1066Campus Bikes IILocked
  69. 1125Smallest Sufficient TeamWatch
  70. 1177Can Make Palindrome from SubstringWatch
  71. 1178Number of Valid Words for Each PuzzleWatch
  72. 1238Circular Permutation in Binary RepresentationWatch
  73. 1239Maximum Length of a Concatenated String with Unique CharactersWatch
  74. 1255Maximum Score Words Formed by LettersWatch
  75. 1256Encode NumberLocked
  76. 1284Minimum Number of Flips to Convert Binary Matrix to Zero MatrixWatch
  77. 1310XOR Queries of a SubarrayWatch
  78. 1318Minimum Flips to Make a OR b Equal to cWatch
  79. 1342Number of Steps to Reduce a Number to ZeroWatch
  80. 1349Maximum Students Taking ExamWatch
  81. 1356Sort Integers by The Number of 1 BitsWatch
  82. 1371Find the Longest Substring Containing Vowels in Even CountsWatch
  83. 1386Cinema Seat AllocationWatch
  84. 1404Number of Steps to Reduce a Number in Binary Representation to OneWatch
  85. 1434Number of Ways to Wear Different Hats to Each OtherWatch
  86. 1442Count Triplets That Can Form Two Arrays of Equal XORWatch
  87. 1457Pseudo-Palindromic Paths in a Binary TreeWatch
  88. 1461Check If a String Contains All Binary Codes of Size KWatch
  89. 1483Kth Ancestor of a Tree NodeWatch
  90. 1486XOR Operation in an ArrayWatch
  91. 1494Parallel Courses IIWatch
  92. 1506Find Root of N-Ary TreeLocked
  93. 1521Find a Value of a Mysterious Function Closest to TargetWatch
  94. 1525Number of Good Ways to Split a StringWatch
  95. 1542Find Longest Awesome SubstringWatch
  96. 1558Minimum Numbers of Function Calls to Make Target ArrayWatch
  97. 1595Minimum Cost to Connect Two Groups of PointsWatch
  98. 1601Maximum Number of Achievable Transfer RequestsWatch
  99. 1611Minimum One Bit Operations to Make Integers ZeroWatch
  100. 1617Count Subtrees With Max Distance Between CitiesWatch
  101. 1655Distribute Repeating IntegersWatch
  102. 1659Maximize Grid HappinessWatch
  103. 1680Concatenation of Consecutive Binary NumbersWatch
  104. 1681Minimum IncompatibilityWatch
  105. 1684Count the Number of Consistent StringsWatch
  106. 1707Maximum XOR With an Element From ArrayWatch
  107. 1720Decode XORed ArrayWatch
  108. 1723Find Minimum Time to Finish All JobsWatch
  109. 1734Decode XORed PermutationWatch
  110. 1738Find Kth Largest XOR Coordinate ValueWatch
  111. 1755Closest Subsequence SumWatch
  112. 1763Longest Nice SubstringWatch
  113. 1787Make the XOR of All Segments Equal to ZeroWatch
  114. 1799Maximize Score After N OperationsWatch
  115. 1803Count Pairs With XOR in a RangeWatch
  116. 1815Maximum Number of Groups Getting Fresh DonutsWatch
  117. 1829Maximum XOR for Each QueryWatch
  118. 1835Find XOR Sum of All Pairs Bitwise ANDWatch
  119. 1863Sum of All Subset XOR TotalsWatch
  120. 1879Minimum XOR Sum of Two ArraysWatch
  121. 1908Game of NimLocked
  122. 1915Number of Wonderful SubstringsWatch
  123. 1930Unique Length-3 Palindromic SubsequencesWatch
  124. 1938Maximum Genetic Difference QueryWatch
  125. 1947Maximum Compatibility Score SumWatch
  126. 1986Minimum Number of Work Sessions to Finish the TasksWatch
  127. 1994The Number of Good SubsetsWatch
  128. 2002Maximum Product of the Length of Two Palindromic SubsequencesWatch
  129. 2032Two Out of ThreeWatch
  130. 2035Partition Array Into Two Arrays to Minimize Sum DifferenceWatch
  131. 2044Count Number of Maximum Bitwise-OR SubsetsWatch
  132. 2128Remove All Ones With Row and Column FlipsLocked
  133. 2135Count Words Obtained After Adding a LetterWatch
  134. 2151Maximum Good People Based on StatementsWatch
  135. 2152Minimum Number of Lines to Cover PointsLocked
  136. 2157Groups of StringsWatch
  137. 2172Maximum AND Sum of ArrayWatch
  138. 2174Remove All Ones With Row and Column Flips IILocked
  139. 2184Number of Ways to Build Sturdy Brick WallLocked
  140. 2206Divide Array Into Equal PairsWatch
  141. 2212Maximum Points in an Archery CompetitionWatch
  142. 2220Minimum Bit Flips to Convert NumberWatch
  143. 2247Maximum Cost of Trip With K HighwaysLocked
  144. 2275Largest Combination With Bitwise AND Greater Than ZeroWatch
  145. 2305Fair Distribution of CookiesWatch
  146. 2306Naming a CompanyWatch
  147. 2317Maximum XOR After Operations Watch
  148. 2322Minimum Score After Removals on a TreeWatch
  149. 2351First Letter to Appear TwiceWatch
  150. 2354Number of Excellent PairsWatch
  151. 2397Maximum Rows Covered by ColumnsWatch
  152. 2401Longest Nice SubarrayWatch
  153. 2403Minimum Time to Kill All MonstersLocked
  154. 2411Smallest Subarrays With Maximum Bitwise ORWatch
  155. 2419Longest Subarray With Maximum Bitwise ANDWatch
  156. 2425Bitwise XOR of All PairingsWatch
  157. 2429Minimize XORWatch
  158. 2433Find The Original Array of Prefix XorWatch
  159. 2438Range Product Queries of PowersWatch
  160. 2505Bitwise OR of All Subsequence SumsLocked
  161. 2506Count Pairs Of Similar StringsWatch
  162. 2527Find Xor-Beauty of ArrayWatch
  163. 2546Apply Bitwise Operations to Make Strings EqualWatch
  164. 2564Substring XOR QueriesWatch
  165. 2568Minimum Impossible ORWatch
  166. 2571Minimum Operations to Reduce an Integer to 0Watch
  167. 2572Count the Number of Square-Free SubsetsWatch
  168. 2588Count the Number of Beautiful SubarraysWatch
  169. 2595Number of Even and Odd BitsWatch
  170. 2657Find the Prefix Common Array of Two ArraysWatch
  171. 2680Maximum ORWatch
  172. 2683Neighboring Bitwise XORWatch
  173. 2708Maximum Strength of a GroupWatch
  174. 2732Find a Good Subset of the MatrixWatch
  175. 2741Special PermutationsWatch
  176. 2749Minimum Operations to Make the Integer ZeroWatch
  177. 2791Count Paths That Can Form a Palindrome in a TreeWatch
  178. 2802Find The K-th Lucky NumberLocked
  179. 2835Minimum Operations to Form Subsequence With Target SumWatch
  180. 2836Maximize Value of Function in a Ball Passing GameWatch
  181. 2846Minimum Edge Weight Equilibrium Queries in a TreeWatch
  182. 2850Minimum Moves to Spread Stones Over GridWatch
  183. 2857Count Pairs of Points With Distance kWatch
  184. 2859Sum of Values at Indices With K Set BitsWatch
  185. 2869Minimum Operations to Collect ElementsWatch
  186. 2871Split Array Into Maximum Number of SubarraysWatch
  187. 2897Apply Operations on Array to Maximize Sum of SquaresWatch
  188. 2917Find the K-or of an ArrayWatch
  189. 2920Maximum Points After Collecting Coins From All NodesWatch
  190. 2932Maximum Strong Pair XOR IWatch
  191. 2935Maximum Strong Pair XOR IIWatch
  192. 2939Maximum Xor ProductWatch
  193. 2959Number of Possible Sets of Closing BranchesWatch
  194. 2980Check if Bitwise OR Has Trailing ZerosWatch
  195. 2992Number of Self-Divisible PermutationsLocked
  196. 2997Minimum Number of Operations to Make Array XOR Equal to KWatch
  197. 3003Maximize the Number of Partitions After OperationsWatch
  198. 3007Maximum Number That Sum of the Prices Is Less Than or Equal to KWatch
  199. 3011Find if Array Can Be SortedWatch
  200. 3022Minimize OR of Remaining Elements Using OperationsWatch
  201. 3064Guess the Number Using Bitwise Questions ILocked
  202. 3068Find the Maximum Sum of Node ValuesWatch
  203. 3094Guess the Number Using Bitwise Questions IILocked
  204. 3095Shortest Subarray With OR at Least K IWatch
  205. 3097Shortest Subarray With OR at Least K IIWatch
  206. 3108Minimum Cost Walk in Weighted GraphWatch
  207. 3116Kth Smallest Amount With Single Denomination CombinationWatch
  208. 3117Minimum Sum of Values by Dividing ArrayWatch
  209. 3133Minimum Array EndWatch
  210. 3141Maximum Hamming DistancesLocked
  211. 3145Find Products of Elements of Big ArrayWatch
  212. 3149Find the Minimum Cost Array PermutationWatch
  213. 3154Find Number of Ways to Reach the K-th StairWatch
  214. 3158Find the XOR of Numbers Which Appear TwiceWatch
  215. 3171Find Subarray With Bitwise OR Closest to KWatch
  216. 3173Bitwise OR of Adjacent ElementsLocked
  217. 3180Maximum Total Reward Using Operations IWatch
  218. 3181Maximum Total Reward Using Operations IIWatch
  219. 3191Minimum Operations to Make Binary Array Elements Equal to One IWatch
  220. 3199Count Triplets with Even XOR Set Bits ILocked
  221. 3209Number of Subarrays With AND Value of KWatch
  222. 3211Generate Binary Strings Without Adjacent ZerosWatch
  223. 3215Count Triplets with Even XOR Set Bits IILocked
  224. 3226Number of Bit Changes to Make Two Integers EqualWatch
  225. 3276Select Cells in Grid With Maximum ScoreWatch
  226. 3283Maximum Number of Moves to Kill All PawnsWatch
  227. 3287Find the Maximum Sequence Value of ArrayWatch
  228. 3304Find the K-th Character in String Game IWatch
  229. 3307Find the K-th Character in String Game IIWatch
  230. 3309Maximum Possible Number by Binary ConcatenationWatch
  231. 3314Construct the Minimum Bitwise Array IWatch
  232. 3315Construct the Minimum Bitwise Array IIWatch
  233. 3344Maximum Sized ArrayLocked
  234. 3370Smallest Number With All Set BitsWatch
  235. 3376Minimum Time to Break Locks IWatch
  236. 3393Count Paths With the Given XOR ValueWatch
  237. 3435Frequencies of Shortest SupersequencesWatch
  238. 3444Minimum Increments for Target Multiples in an ArrayWatch
  239. 3495Minimum Operations to Make Array Elements ZeroWatch
  240. 3513Number of Unique XOR Triplets IWatch
  241. 3514Number of Unique XOR Triplets IIWatch
  242. 3526Range XOR Queries with Subarray ReversalsLocked
  243. 3530Maximum Profit from Valid Topological Order in DAGWatch
  244. 3533Concatenated DivisibilityWatch
  245. 3534Path Existence Queries in a Graph IIWatch
  246. 3539Find Sum of Array Product of Magical SequencesWatch
  247. 3553Minimum Weighted Subgraph With the Required Paths IIWatch
  248. 3559Number of Ways to Assign Edge Weights IIWatch
  249. 3566Partition Array into Two Equal Product SubsetsWatch
  250. 3568Minimum Moves to Clean the ClassroomWatch
  251. 3575Maximum Good Subtree ScoreWatch
  252. 3585Find Weighted Median Node in TreeWatch
  253. 3594Minimum Time to Transport All IndividualsWatch
  254. 3595Once TwiceLocked
  255. 3599Partition Array to Minimize XORWatch
  256. 3615Longest Palindromic Path in GraphWatch
  257. 3621Number of Integers With Popcount-Depth Equal to K IWatch
  258. 3630Partition Array for Maximum XOR and ANDWatch
  259. 3632Subarrays with XOR at Least KLocked
  260. 3644Maximum K to Sort a PermutationWatch
  261. 3646Next Special Palindrome NumberWatch
  262. 3670Maximum Product of Two Integers With No Common BitsWatch
  263. 3674Minimum Operations to Equalize ArrayWatch
  264. 3677Count Binary Palindromic NumbersWatch
  265. 3681Maximum XOR of SubsequencesWatch
  266. 3688Bitwise OR of Even Numbers in an ArrayWatch
  267. 3702Longest Subsequence With Non-Zero Bitwise XORWatch
  268. 3750Minimum Number of Flips to Reverse Binary StringWatch
  269. 3755Find Maximum Balanced XOR Subarray LengthWatch
  270. 3757Number of Effective SubsequencesWatch
  271. 3766Minimum Operations to Make Binary PalindromeWatch
  272. 3801Minimum Cost to Merge Sorted ListsWatch
  273. 3806Maximum Bitwise AND After Increment OperationsWatch
  274. 3811Number of Alternating XOR PartitionsWatch
  275. 3821Find Nth Smallest Integer With K One BitsWatch
  276. 3825Longest Strictly Increasing Subsequence With Non-Zero Bitwise ANDWatch
  277. 3827Count Monobit IntegersWatch
  278. 3841Palindromic Path Queries in a TreeWatch
  279. 3845Maximum Subarray XOR with Bounded RangeWatch
  280. 3849Maximum Bitwise XOR After RearrangementWatch
  281. 3858Minimum Bitwise OR From GridWatch
  282. 3877Minimum Removals to Achieve Target XORWatch
  283. 3878Count Good SubarraysWatch
  284. 3882Minimum XOR Path in a GridWatch
  285. 3910Count Connected Subgraphs with Even Node SumWatch
  286. 3950Exactly One Consecutive Set Bits PairWatch
  287. 3954Sum of Compatible Numbers in Range IWatch
  288. 3955Valid Binary Strings With Cost LimitWatch
  289. 3973Distinct Gate Paths to LCALocked
  290. 3990Create Grid With Exactly K Paths IILocked
  291. 4027Elevator Requests IIIWatch
  292. 4030Check ASCII PalindromicWatch
  293. 4033Valid K-Unique Subarrays IWatch
  294. 4036Lexicographically Largest String After Pair TransformationsWatch
  295. 4042Valid K-Unique Subarrays IILocked
  296. 4047Minimum Operations to Make XOR of All Elements ZeroLocked