LeetCodechevron_rightCategorieschevron_rightbit manipulation
memory

bit manipulation

220 problems
Easy: 45Medium: 97Hard: 78

bit manipulation is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.

Interview Signal

Frequently tests problem modeling, edge handling, and verbal clarity.

Common Pitfall

Template-only answers break under follow-up questioning.

Practice Strategy

Practice in 3-5 problem rounds and always review complexity alternatives.

Recommended Progression

#TitleDifficulty
29

Divide Two Integers

Solve Divide Two Integers by turning repeated subtraction into bit-shifted chunk subtraction with careful sign and overf…

Medium
67

Add Binary

Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…

Easy
78

Subsets

Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.

Medium
89

Gray Code

Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.

Medium
90

Subsets II

Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…

Medium
136

Single Number

Solve the Single Number problem using an efficient approach with constant space and linear time complexity.

Easy
137

Single Number II

Find the single element in an array where every other element appears three times, using bit manipulation and constant s…

Medium
187

Repeated DNA Sequences

Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.

Medium
190

Reverse Bits

Reverse a 32-bit unsigned integer by manipulating bits efficiently using a divide and conquer approach with careful bit …

Easy
191

Number of 1 Bits

Number of 1 Bits is a classic bit manipulation problem where clearing the lowest set bit gives the cleanest count.

Easy
201

Bitwise AND of Numbers Range

Use shared high bits and bit clearing to solve Bitwise AND of Numbers Range without scanning every value.

Medium
222

Count Complete Tree Nodes

Count Complete Tree Nodes efficiently by leveraging binary-tree traversal, exploiting completeness, and applying bit man…

Easy
231

Power of Two

Determine if a given integer is a power of two using efficient math and bit manipulation techniques with optional recurs…

Easy
260

Single Number III

Find the two unique numbers in an array where all other numbers appear exactly twice using bit manipulation efficiently.

Medium
268

Missing Number

Find the missing number in an array containing distinct numbers in the range [0, n].

Easy
287

Find the Duplicate Number

The problem involves finding the duplicate number in an array of integers, using a binary search approach over the valid…

Medium
318

Maximum Product of Word Lengths

The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…

Medium
338

Counting Bits

Compute the number of 1 bits for every integer from 0 to n using state transition dynamic programming for efficiency.

Easy
342

Power of Four

Determine if a given integer is a power of four using math insights and bit manipulation tricks efficiently in code.

Easy
371

Sum of Two Integers

Solve the Sum of Two Integers problem using bit manipulation and math to avoid using the operators + and -.

Medium
389

Find the Difference

Find the Difference involves identifying the additional letter in one string compared to another, emphasizing hash table…

Easy
393

UTF-8 Validation

Determine if an integer array represents valid UTF-8 encoding based on its byte sequences using bit manipulation.

Medium
397

Integer Replacement

Find the minimum number of operations to reduce a number to 1 by applying specific operations, using state transition dy…

Medium
401

Binary Watch

Binary Watch involves generating possible times on a binary watch given a number of turned-on LEDs.

Easy
405

Convert a Number to Hexadecimal

Convert a 32-bit integer to its hexadecimal string using math operations and careful string manipulation techniques.

Easy
421

Maximum XOR of Two Numbers in an Array

Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.

Medium
461

Hamming Distance

Calculate the Hamming distance between two integers by counting differing bit positions.

Easy
464

Can I Win

Determine if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…

Medium
473

Matchsticks to Square

The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…

Medium
476

Number Complement

The Number Complement problem requires flipping bits in a number’s binary representation to return its complement.

Easy
477

Total Hamming Distance

Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.

Medium
491

Non-decreasing Subsequences

Return all possible non-decreasing subsequences with at least two elements from the input array, nums.

Medium
526

Beautiful Arrangement

The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…

Medium
638

Shopping Offers

Minimize the cost of purchasing items using available special offers with state transition dynamic programming.

Medium
645

Set Mismatch

Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…

Easy
672

Bulb Switcher II

Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.

Medium
691

Stickers to Spell Word

Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…

Hard
693

Binary Number with Alternating Bits

Check whether a given integer has alternating bits using a bit manipulation approach.

Easy
698

Partition to K Equal Sum Subsets

Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…

Medium
756

Pyramid Transition Matrix

The Pyramid Transition Matrix problem requires determining whether a pyramid can be formed with given blocks and valid p…

Medium
762

Prime Number of Set Bits in Binary Representation

Count numbers with prime set bits in a binary representation within a given range.

Easy
779

K-th Symbol in Grammar

Determine the K-th symbol in a recursively generated grammar table using math and bit manipulation patterns efficiently.

Medium
782

Transform to Chessboard

Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.

Hard
784

Letter Case Permutation

Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.

Medium
805

Split Array With Same Average

Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…

Hard
810

Chalkboard XOR Game

The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…

Hard
832

Flipping an Image

Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.

Easy
847

Shortest Path Visiting All Nodes

Solve the Shortest Path Visiting All Nodes problem by exploring dynamic programming, bit manipulation, and breadth-first…

Hard
861

Score After Flipping Matrix

Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.

Medium
864

Shortest Path to Get All Keys

Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.

Hard
868

Binary Gap

Find the maximum distance between consecutive 1's in a number's binary form using precise bit manipulation techniques.

Easy
898

Bitwise ORs of Subarrays

Compute the number of unique bitwise OR values from all non-empty subarrays using dynamic state transitions efficiently.

Medium
943

Find the Shortest Superstring

This problem requires constructing the shortest string containing all input words using state transition dynamic program…

Hard
957

Prison Cells After N Days

Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…

Medium
980

Unique Paths III

Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…

Hard
982

Triples with Bitwise AND Equal To Zero

Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…

Hard
995

Minimum Number of K Consecutive Bit Flips

Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…

Hard
996

Number of Squareful Arrays

Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…

Hard
1009

Complement of Base 10 Integer

In this problem, you need to return the complement of a given integer by flipping its binary digits.

Easy
1016

Binary String With Substrings Representing 1 To N

Check if binary string contains all integers from 1 to n as substrings, leveraging sliding window and bit manipulation t…

Medium
1018

Binary Prefix Divisible By 5

Determine which binary prefixes of a given array are divisible by 5 using bit manipulation for efficient checks.

Easy
1125

Smallest Sufficient Team

Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…

Hard
1177

Can Make Palindrome from Substring

Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.

Medium
1178

Number of Valid Words for Each Puzzle

Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…

Hard
1238

Circular Permutation in Binary Representation

Generate a circular permutation from a range of numbers using backtracking and bit manipulation.

Medium
1239

Maximum Length of a Concatenated String with Unique Characters

Find the maximum length of a concatenated string from an array with all unique characters using backtracking search with…

Medium
1255

Maximum Score Words Formed by Letters

Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…

Hard
1284

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…

Hard
1310

XOR Queries of a Subarray

Compute XOR results for multiple subarray queries using efficient prefix XOR to reduce repeated computation overhead in …

Medium
1318

Minimum Flips to Make a OR b Equal to c

Determine the minimum number of bit flips required in two integers so that their OR equals a target integer efficiently.

Medium
1342

Number of Steps to Reduce a Number to Zero

Reduce a number to zero using bit manipulation and math. Simulate the process step-by-step based on whether the number i…

Easy
1349

Maximum Students Taking Exam

Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…

Hard
1356

Sort Integers by The Number of 1 Bits

Sort an array of integers by the number of 1's in their binary representation and then by their value in case of ties.

Easy
1371

Find the Longest Substring Containing Vowels in Even Counts

Find the longest substring with even counts of vowels using bitmasking and hash tables.

Medium
1386

Cinema Seat Allocation

Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…

Medium
1404

Number of Steps to Reduce a Number in Binary Representation to One

Determine the number of steps to reduce a binary representation of a number to 1 by following specific rules.

Medium
1434

Number of Ways to Wear Different Hats to Each Other

Calculate all unique assignments of hats to people using state transition dynamic programming with bitmasking for collis…

Hard
1442

Count Triplets That Can Form Two Arrays of Equal XOR

Efficiently count all triplets in an array where two subarrays formed by splitting have equal XOR using array scanning a…

Medium
1457

Pseudo-Palindromic Paths in a Binary Tree

Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.

Medium
1461

Check If a String Contains All Binary Codes of Size K

Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…

Medium
1486

XOR Operation in an Array

Compute the bitwise XOR of a dynamically generated array using a combination of math and bit manipulation techniques eff…

Easy
1494

Parallel Courses II

Determine the minimum semesters to complete all courses with prerequisites using state transition dynamic programming an…

Hard
1521

Find a Value of a Mysterious Function Closest to Target

In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.

Hard
1525

Number of Good Ways to Split a String

Count all valid splits of a string where left and right substrings have equal distinct characters, using efficient state…

Medium
1542

Find Longest Awesome Substring

Find the maximum-length awesome substring in a numeric string using hash table and bit manipulation for palindrome poten…

Hard
1558

Minimum Numbers of Function Calls to Make Target Array

Calculate the minimum number of modify calls needed to convert an all-zero array into a given target array using greedy …

Medium
1595

Minimum Cost to Connect Two Groups of Points

Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.

Hard
1601

Maximum Number of Achievable Transfer Requests

Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.

Hard
1611

Minimum One Bit Operations to Make Integers Zero

Compute the minimum number of one-bit operations to convert a given integer to zero using state transition dynamic progr…

Hard
1617

Count Subtrees With Max Distance Between Cities

This problem asks you to count subtrees in a tree structure where the maximum distance between any two cities matches sp…

Hard
1655

Distribute Repeating Integers

Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…

Hard
1659

Maximize Grid Happiness

Maximize Grid Happiness is a dynamic programming problem focusing on state transitions with bitmasking to maximize happi…

Hard
1680

Concatenation of Consecutive Binary Numbers

Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.

Medium
1681

Minimum Incompatibility

Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.

Hard
1684

Count the Number of Consistent Strings

Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.

Easy
1707

Maximum XOR With an Element From Array

Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…

Hard
1720

Decode XORed Array

Recover the original integer array from its XOR-encoded version using direct bitwise manipulation and sequential reconst…

Easy
1723

Find Minimum Time to Finish All Jobs

Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…

Hard
1734

Decode XORed Permutation

Decode XORed Permutation uses prefix reconstruction with global XOR to recover the hidden odd-length permutation in line…

Medium
1738

Find Kth Largest XOR Coordinate Value

Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…

Medium
1755

Closest Subsequence Sum

Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…

Hard
1763

Longest Nice Substring

Find the longest nice substring in a given string using the sliding window technique with running state updates.

Easy
1787

Make the XOR of All Segments Equal to Zero

Determine the minimum changes needed in an array so all size-k segments XOR to zero using DP and bit manipulation.

Hard
1799

Maximize Score After N Operations

Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …

Hard
1803

Count Pairs With XOR in a Range

Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …

Hard
1815

Maximum Number of Groups Getting Fresh Donuts

Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…

Hard
1829

Maximum XOR for Each Query

Find the maximum XOR for each query based on a sorted array and bit manipulation.

Medium
1835

Find XOR Sum of All Pairs Bitwise AND

Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.

Hard
1863

Sum of All Subset XOR Totals

Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.

Easy
1879

Minimum XOR Sum of Two Arrays

Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.

Hard
1915

Number of Wonderful Substrings

Count the number of wonderful non-empty substrings of a given string based on frequency conditions of characters.

Medium
1930

Unique Length-3 Palindromic Subsequences

Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.

Medium
1938

Maximum Genetic Difference Query

Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.

Hard
1947

Maximum Compatibility Score Sum

Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…

Medium
1986

Minimum Number of Work Sessions to Finish the Tasks

Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.

Medium
1994

The Number of Good Subsets

Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.

Hard
2002

Maximum Product of the Length of Two Palindromic Subsequences

Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…

Medium
2032

Two Out of Three

Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…

Easy
2035

Partition Array Into Two Arrays to Minimize Sum Difference

Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…

Hard
2044

Count Number of Maximum Bitwise-OR Subsets

Determine the number of non-empty subsets that achieve the maximum bitwise OR using efficient backtracking and pruning s…

Medium
2135

Count Words Obtained After Adding a Letter

Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …

Medium
2151

Maximum Good People Based on Statements

Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.

Hard
2157

Groups of Strings

Group words into connected sets using operations on characters with string and bit manipulation techniques.

Hard
2172

Maximum AND Sum of Array

Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.

Hard
2206

Divide Array Into Equal Pairs

Determine if an array of 2n integers can be partitioned into n pairs where each pair contains identical elements using h…

Easy
2212

Maximum Points in an Archery Competition

In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…

Medium
2220

Minimum Bit Flips to Convert Number

Determine the minimum number of bit flips required to convert one integer to another using precise bit manipulation.

Easy
2275

Largest Combination With Bitwise AND Greater Than Zero

Find the largest group of integers in an array whose bitwise AND is greater than zero using array scanning and hash look…

Medium
2305

Fair Distribution of Cookies

The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…

Medium
2306

Naming a Company

The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…

Hard
2317

Maximum XOR After Operations

Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.

Medium
2322

Minimum Score After Removals on a Tree

Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.

Hard
2351

First Letter to Appear Twice

Find the first letter that repeats in a string using hash table tracking and early detection for efficiency.

Easy
2354

Number of Excellent Pairs

Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…

Hard
2397

Maximum Rows Covered by Columns

Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…

Medium
2401

Longest Nice Subarray

Find the length of the longest nice subarray where the bitwise AND of all pairs of elements in the subarray is zero.

Medium
2411

Smallest Subarrays With Maximum Bitwise OR

Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.

Medium
2419

Longest Subarray With Maximum Bitwise AND

Find the length of the longest subarray whose bitwise AND reaches the array's maximum value, combining array scanning wi…

Medium
2425

Bitwise XOR of All Pairings

Compute the overall bitwise XOR from all pairings between two arrays using efficient array and bit manipulation techniqu…

Medium
2429

Minimize XOR

Minimize XOR problem asks for an integer that minimizes XOR with another, applying greedy choices for bit manipulation.

Medium
2433

Find The Original Array of Prefix Xor

Find the original array from a given prefix XOR array using bitwise manipulation techniques.

Medium
2438

Range Product Queries of Powers

The Range Product Queries of Powers problem requires calculating the product of powers of 2 for a range of queries on a …

Medium
2506

Count Pairs Of Similar Strings

Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…

Easy
2527

Find Xor-Beauty of Array

Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.

Medium
2546

Apply Bitwise Operations to Make Strings Equal

Determine if a binary string s can be transformed into target using repeated bitwise operations on paired indices effici…

Medium
2564

Substring XOR Queries

Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…

Medium
2568

Minimum Impossible OR

Find the smallest positive integer that cannot be formed from any subsequence OR combination in the array.

Medium
2571

Minimum Operations to Reduce an Integer to 0

Compute the minimum number of operations to reduce a positive integer to zero using additions or subtractions of powers …

Medium
2572

Count the Number of Square-Free Subsets

Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…

Medium
2588

Count the Number of Beautiful Subarrays

Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…

Medium
2595

Number of Even and Odd Bits

Count the number of 1s at even and odd indices in the binary representation of a given integer n.

Easy
2657

Find the Prefix Common Array of Two Arrays

This problem challenges you to find the prefix common array of two integer permutations, utilizing array scanning and ha…

Medium
2680

Maximum OR

Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.

Medium
2683

Neighboring Bitwise XOR

Determine if a binary array original exists that produces the given derived array using neighboring bitwise XOR logic.

Medium
2708

Maximum Strength of a Group

Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…

Medium
2732

Find a Good Subset of the Matrix

Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…

Hard
2741

Special Permutations

Count the number of special permutations for a given array using dynamic programming and bit manipulation.

Medium
2749

Minimum Operations to Make the Integer Zero

This problem challenges you to compute the minimum operations to reduce an integer to zero using bit manipulation and st…

Medium
2791

Count Paths That Can Form a Palindrome in a Tree

This problem asks you to count all node pairs in a tree whose path characters can be rearranged into a palindrome using …

Hard
2835

Minimum Operations to Form Subsequence With Target Sum

The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …

Hard
2836

Maximize Value of Function in a Ball Passing Game

Maximize the total score in a ball-passing game by selecting the best starting player using state transition dynamic pro…

Hard
2857

Count Pairs of Points With Distance k

Solve the problem of counting pairs of points with distance k using array scanning and hash table techniques.

Medium
2859

Sum of Values at Indices With K Set Bits

Sum values in an array where the indices have exactly k set bits in binary representation.

Easy
2869

Minimum Operations to Collect Elements

Scan from the end, track seen values from 1 to k, and stop once every required number is collected.

Easy
2871

Split Array Into Maximum Number of Subarrays

Maximize the number of subarrays in an array while ensuring each subarray's bitwise AND meets the minimum score requirem…

Medium
2897

Apply Operations on Array to Maximize Sum of Squares

Maximizing the sum of squares in an array through bitwise operations on selected elements.

Hard
2917

Find the K-or of an Array

Given an integer array nums and an integer k, find the K-or of nums where bits qualify based on the occurrence of 1s.

Easy
2920

Maximum Points After Collecting Coins From All Nodes

Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.

Hard
2932

Maximum Strong Pair XOR I

Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.

Easy
2935

Maximum Strong Pair XOR II

Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.

Hard
2939

Maximum Xor Product

Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.

Medium
2959

Number of Possible Sets of Closing Branches

Calculate all valid sets of branch closures while keeping remaining branches within maxDistance using bitmask and graph …

Hard
2980

Check if Bitwise OR Has Trailing Zeros

Check if a bitwise OR of two or more numbers has trailing zeros in its binary representation.

Easy
2997

Minimum Number of Operations to Make Array XOR Equal to K

Find the minimum number of operations to make the XOR of an array equal to a given value k by modifying array elements.

Medium
3003

Maximize the Number of Partitions After Operations

Maximizing the number of partitions in a string after changing one character and applying partitioning operations using …

Hard
3007

Maximum Number That Sum of the Prices Is Less Than or Equal to K

Find the greatest number whose accumulated price, based on binary set bit positions, is less than or equal to k.

Medium
3011

Find if Array Can Be Sorted

Determine if a given array can be sorted using adjacent swaps restricted by equal set bits in binary representation.

Medium
3022

Minimize OR of Remaining Elements Using Operations

Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.

Hard
3068

Find the Maximum Sum of Node Values

Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…

Hard
3095

Shortest Subarray With OR at Least K I

Find the shortest non-empty subarray in nums whose bitwise OR reaches at least k using sliding window efficiently.

Easy
3097

Shortest Subarray With OR at Least K II

Find the length of the shortest subarray where the bitwise OR of all its elements is at least a given value.

Medium
3108

Minimum Cost Walk in Weighted Graph

Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…

Hard
3116

Kth Smallest Amount With Single Denomination Combination

Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…

Hard
3117

Minimum Sum of Values by Dividing Array

Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.

Hard
3133

Minimum Array End

Construct an array where elements are greater than the previous one, and the bitwise AND of all elements equals a given …

Medium
3145

Find Products of Elements of Big Array

Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…

Hard
3149

Find the Minimum Cost Array Permutation

Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…

Hard
3154

Find Number of Ways to Reach the K-th Stair

Determine the total number of ways to reach the k-th stair using a state transition dynamic programming approach with co…

Hard
3158

Find the XOR of Numbers Which Appear Twice

Find the XOR of numbers appearing twice by scanning the array and using a hash table for efficient tracking and combinat…

Easy
3171

Find Subarray With Bitwise OR Closest to K

Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.

Hard
3181

Maximum Total Reward Using Operations II

Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …

Hard
3191

Minimum Operations to Make Binary Array Elements Equal to One I

Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…

Medium
3209

Number of Subarrays With AND Value of K

The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…

Hard
3211

Generate Binary Strings Without Adjacent Zeros

Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…

Medium
3226

Number of Bit Changes to Make Two Integers Equal

Find the number of bit changes to make two integers equal using bit manipulation techniques.

Easy
3276

Select Cells in Grid With Maximum Score

Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.

Hard
3283

Maximum Number of Moves to Kill All Pawns

Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…

Hard
3287

Find the Maximum Sequence Value of Array

Determine the maximum value of a subsequence in an integer array using state transition dynamic programming and bit oper…

Hard
3304

Find the K-th Character in String Game I

Find the K-th character in a progressively built string using math and bit manipulation efficiently.

Easy
3307

Find the K-th Character in String Game II

Find the K-th character in a string game using bit manipulation and recursion, optimizing performance for large k values…

Hard
3309

Maximum Possible Number by Binary Concatenation

Determine the largest number achievable by reordering three integers and concatenating their binary forms efficiently.

Medium
3314

Construct the Minimum Bitwise Array I

Learn how to construct an array minimizing each element while matching given primes using bitwise operations efficiently…

Easy
3315

Construct the Minimum Bitwise Array II

Learn to build the minimum array matching a bitwise OR pattern for each prime in nums, focusing on binary optimization.

Medium
3370

Smallest Number With All Set Bits

Find the smallest number greater than or equal to n with all set bits in its binary representation.

Easy
3376

Minimum Time to Break Locks I

Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…

Medium
3393

Count Paths With the Given XOR Value

Count the number of paths in a grid where the XOR of all values along the path equals a given number.

Medium
3435

Frequencies of Shortest Supersequences

Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …

Hard
3444

Minimum Increments for Target Multiples in an Array

This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…

Hard
3495

Minimum Operations to Make Array Elements Zero

Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…

Hard
3513

Number of Unique XOR Triplets I

Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…

Medium
3514

Number of Unique XOR Triplets II

Count all unique XOR results from triplets in an integer array using array traversal and bit manipulation techniques eff…

Medium
3530

Maximum Profit from Valid Topological Order in DAG

Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…

Hard
3533

Concatenated Divisibility

Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …

Hard
3539

Find Sum of Array Product of Magical Sequences

Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…

Hard
3566

Partition Array into Two Equal Product Subsets

Determine if you can partition an array into two subsets with equal product using recursion and bit manipulation.

Medium
3568

Minimum Moves to Clean the Classroom

Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.

Medium
3575

Maximum Good Subtree Score

Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…

Hard
3594

Minimum Time to Transport All Individuals

Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.

Hard
3599

Partition Array to Minimize XOR

Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…

Medium
3615

Longest Palindromic Path in Graph

Find the longest path in a graph that forms a palindrome using state transition dynamic programming and bitmask techniqu…

Hard

Related Patterns

Bit Manipulation LeetCode Problems: 220 Solutions