Bit Manipulation Problems
Master bit manipulation problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 142 problems in this category.
Total Problems: 142
Easy: 36
Medium: 63
Hard: 43
Showing 50 of 142 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Bit Manipulation LeetCode Problems List
- 268. Missing Number - Easy - Bit ManipulationGiven an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.... Topics: Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
- 67. Add Binary - Easy - Bit ManipulationGiven two binary strings a and b, return their sum as a binary string.... Topics: Math, String, Bit Manipulation, Simulation
- 190. Reverse Bits - Easy - Bit ManipulationReverse bits of a given 32 bits signed integer.... Topics: Divide and Conquer, Bit Manipulation
- 222. Count Complete Tree Nodes - Easy - Bit ManipulationGiven the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, i... Topics: Binary Search, Bit Manipulation, Tree, Binary Tree
- 78. Subsets - Medium - Bit ManipulationGiven an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Retu... Topics: Array, Backtracking, Bit Manipulation
- 287. Find the Duplicate Number - Medium - Bit ManipulationGiven an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nu... Topics: Array, Two Pointers, Binary Search, Bit Manipulation
- 231. Power of Two - Easy - Bit ManipulationGiven an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such th... Topics: Math, Bit Manipulation, Recursion
- 136. Single Number - Easy - Bit ManipulationGiven a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linea... Topics: Array, Bit Manipulation
- 29. Divide Two Integers - Medium - Bit ManipulationGiven two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. The integer division should tru... Topics: Math, Bit Manipulation
- 461. Hamming Distance - Easy - Bit ManipulationThe Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, return... Topics: Bit Manipulation
- 89. Gray Code - Medium - Bit ManipulationAn n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An intege... Topics: Math, Backtracking, Bit Manipulation
- 371. Sum of Two Integers - Medium - Bit ManipulationGiven two integers a and b, return the sum of the two integers without using the operators + and -.... Topics: Math, Bit Manipulation
- 137. Single Number II - Medium - Bit ManipulationGiven an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it.... Topics: Array, Bit Manipulation
- 861. Flipping an Image - Easy - Bit ManipulationGiven an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means t... Topics: Array, Two Pointers, Bit Manipulation, Matrix, Simulation
- 342. Power of Four - Easy - Bit ManipulationGiven an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such ... Topics: Math, Bit Manipulation, Recursion
- 698. Partition to K Equal Sum Subsets - Medium - Bit ManipulationGiven an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 464. Can I Win - Medium - Bit ManipulationIn the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach ... Topics: Math, Dynamic Programming, Bit Manipulation, Memoization, Game Theory, Bitmask
- 638. Shopping Offers - Medium - Bit ManipulationIn LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or mo... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 2323. Minimum Bit Flips to Convert Number - Easy - Bit ManipulationA bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0. For example, for x = 7, the... Topics: Bit Manipulation
- 800. Letter Case Permutation - Medium - Bit ManipulationGiven a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible str... Topics: String, Backtracking, Bit Manipulation
- 405. Convert a Number to Hexadecimal - Easy - Bit ManipulationGiven a 32-bit integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. All t... Topics: Math, String, Bit Manipulation
- 877. Shortest Path Visiting All Nodes - Hard - Bit ManipulationYou have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes con... Topics: Dynamic Programming, Bit Manipulation, Breadth-First Search, Graph, Bitmask
- 389. Find the Difference - Easy - Bit ManipulationYou are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the le... Topics: Hash Table, String, Bit Manipulation, Sorting
- 421. Maximum XOR of Two Numbers in an Array - Medium - Bit ManipulationGiven an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.... Topics: Array, Hash Table, Bit Manipulation, Trie
- 1444. Number of Steps to Reduce a Number to Zero - Easy - Bit ManipulationGiven an integer num, return the number of steps to reduce it to zero. In one step, if the current number is even, you have to divide it by 2, otherwi... Topics: Math, Bit Manipulation
- 90. Subsets II - Medium - Bit ManipulationGiven an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subs... Topics: Array, Backtracking, Bit Manipulation
- 191. Number of 1 Bits - Easy - Bit ManipulationGiven a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).... Topics: Divide and Conquer, Bit Manipulation
- 1022. Unique Paths III - Hard - Bit ManipulationYou are given an m x n integer array grid where grid[i][j] could be: 1 representing the starting square. There is exactly one starting square. 2 repre... Topics: Array, Backtracking, Bit Manipulation, Matrix
- 1825. Find Minimum Time to Finish All Jobs - Hard - Bit ManipulationYou are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job. There are k workers that you can assign job... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 691. Stickers to Spell Word - Hard - Bit ManipulationWe are given n different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given string target by cu... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 338. Counting Bits - Easy - Bit ManipulationGiven an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation o... Topics: Dynamic Programming, Bit Manipulation
- 1458. Sort Integers by The Number of 1 Bits - Easy - Bit ManipulationYou are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case ... Topics: Array, Bit Manipulation, Sorting, Counting
- 3197. Maximum Strong Pair XOR II - Hard - Bit ManipulationYou are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition: |x - y| <= min(x, y) Y... Topics: Array, Hash Table, Bit Manipulation, Trie, Sliding Window
- 526. Beautiful Arrangement - Medium - Bit ManipulationSuppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2162. Partition Array Into Two Arrays to Minimize Sum Difference - Hard - Bit ManipulationYou are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of t... Topics: Array, Two Pointers, Binary Search, Dynamic Programming, Bit Manipulation, Ordered Set, Bitmask
- 795. K-th Symbol in Grammar - Medium - Bit ManipulationWe build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace eac... Topics: Math, Bit Manipulation, Recursion
- 2078. Maximum Compatibility Score Sum - Medium - Bit ManipulationThere is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes). The survey was given to m students numbered f... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 1993. Sum of All Subset XOR Totals - Easy - Bit ManipulationThe XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For example, the XOR total of the array [2,5,... Topics: Array, Math, Backtracking, Bit Manipulation, Combinatorics, Enumeration
- 3428. Find the XOR of Numbers Which Appear Twice - Easy - Bit ManipulationYou are given an array nums, where each number in the array appears either once or twice. Return the bitwise XOR of all the numbers that appear twice ... Topics: Array, Hash Table, Bit Manipulation
- 1360. Maximum Length of a Concatenated String with Unique Characters - Medium - Bit ManipulationYou are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the maximu... Topics: Array, String, Backtracking, Bit Manipulation
- 934. Bitwise ORs of Subarrays - Medium - Bit ManipulationGiven an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr. The bitwise OR of a subarray is the bitwi... Topics: Array, Dynamic Programming, Bit Manipulation
- 393. UTF-8 Validation - Medium - Bit ManipulationGiven an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e. it translates to a sequence of valid UTF-8 encode... Topics: Array, Bit Manipulation
- 1786. Count the Number of Consistent Strings - Easy - Bit ManipulationYou are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string... Topics: Array, Hash Table, String, Bit Manipulation, Counting
- 1054. Complement of Base 10 Integer - Easy - Bit ManipulationThe complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example,... Topics: Bit Manipulation
- 2170. Count Number of Maximum Bitwise-OR Subsets - Medium - Bit ManipulationGiven an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the ma... Topics: Array, Backtracking, Bit Manipulation, Enumeration
- 476. Number Complement - Easy - Bit ManipulationThe complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example,... Topics: Bit Manipulation
- 473. Matchsticks to Square - Medium - Bit ManipulationYou are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one s... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 1587. Parallel Courses II - Hard - Bit ManipulationYou are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [... Topics: Dynamic Programming, Bit Manipulation, Graph, Bitmask
- 260. Single Number III - Medium - Bit ManipulationGiven an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements tha... Topics: Array, Bit Manipulation
- 767. Prime Number of Set Bits in Binary Representation - Easy - Bit ManipulationGiven two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary ... Topics: Math, Bit Manipulation
- 994. Prison Cells After N Days - Medium - Bit ManipulationThere are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to th... Topics: Array, Hash Table, Math, Bit Manipulation
- 645. Set Mismatch - Easy - Bit ManipulationYou have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got dup... Topics: Array, Hash Table, Bit Manipulation, Sorting
- 3601. Find the K-th Character in String Game II - Hard - Bit ManipulationAlice and Bob are playing a game. Initially, Alice has a string word = "a". You are given a positive integer k. You are also given an integer array op... Topics: Math, Bit Manipulation, Recursion
- 187. Repeated DNA Sequences - Medium - Bit ManipulationThe DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When study... Topics: Hash Table, String, Bit Manipulation, Sliding Window, Rolling Hash, Hash Function
- 3093. Sum of Values at Indices With K Set Bits - Easy - Bit ManipulationYou are given a 0-indexed integer array nums and an integer k. Return an integer that denotes the sum of elements in nums whose corresponding indices ... Topics: Array, Bit Manipulation
- 891. Score After Flipping Matrix - Medium - Bit ManipulationYou are given an m x n binary matrix grid. A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing... Topics: Array, Greedy, Bit Manipulation, Matrix
- 1826. Maximum XOR With an Element From Array - Hard - Bit ManipulationYou are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi]. The answer to the it... Topics: Array, Bit Manipulation, Trie
- 2044. Number of Wonderful Substrings - Medium - Bit ManipulationA wonderful string is a string where at most one letter appears an odd number of times. For example, "ccjjc" and "abab" are wonderful, but "ab" is not... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 1471. Maximum Students Taking Exam - Hard - Bit ManipulationGiven a m * n matrix seats that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is den... Topics: Array, Dynamic Programming, Bit Manipulation, Matrix, Bitmask
- 2632. Apply Bitwise Operations to Make Strings Equal - Medium - Bit ManipulationYou are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times: Choose two ... Topics: String, Bit Manipulation
- 1531. Number of Ways to Wear Different Hats to Each Other - Hard - Bit ManipulationThere are n people and 40 types of hats labeled from 1 to 40. Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith ... Topics: Array, Dynamic Programming, Bit Manipulation, Bitmask
- 3249. Minimum Number of Operations to Make Array XOR Equal to K - Medium - Bit ManipulationYou are given a 0-indexed integer array nums and a positive integer k. You can apply the following operation on the array any number of times: Choose ... Topics: Array, Bit Manipulation
- 2766. Find the Prefix Common Array of Two Arrays - Medium - Bit ManipulationYou are given two 0-indexed integer permutations A and B of length n. A prefix common array of A and B is an array C such that C[i] is equal to the co... Topics: Array, Hash Table, Bit Manipulation
- 1282. Number of Valid Words for Each Puzzle - Hard - Bit ManipulationWith respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For e... Topics: Array, Hash Table, String, Bit Manipulation, Trie
- 3649. Minimum Time to Break Locks I - Medium - Bit ManipulationBob is stuck in a dungeon and must break n locks, each requiring some amount of energy to break. The required energy for each lock is stored in an arr... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Depth-First Search, Bitmask
- 3913. Partition Array to Minimize XOR - Medium - Bit ManipulationYou are given an integer array nums and an integer k. Your task is to partition nums into k non-empty subarrays. For each subarray, compute the bitwis... Topics: Array, Dynamic Programming, Bit Manipulation, Prefix Sum
- 201. Bitwise AND of Numbers Range - Medium - Bit ManipulationGiven two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.... Topics: Bit Manipulation
- 1732. Minimum One Bit Operations to Make Integers Zero - Hard - Bit ManipulationGiven an integer n, you must transform it into 0 using the following operations any number of times: Change the rightmost (0th) bit in the binary repr... Topics: Dynamic Programming, Bit Manipulation, Memoization
- 3930. Longest Palindromic Path in Graph - Hard - Bit ManipulationYou are given an integer n and an undirected graph with n nodes labeled from 0 to n - 1 and a 2D array edges, where edges[i] = [ui, vi] indicates an e... Topics: String, Dynamic Programming, Bit Manipulation, Graph, Bitmask
- 1065. Binary String With Substrings Representing 1 To N - Medium - Bit ManipulationGiven a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s... Topics: Hash Table, String, Bit Manipulation, Sliding Window
- 2503. Longest Subarray With Maximum Bitwise AND - Medium - Bit ManipulationYou are given an integer array nums of size n. Consider a non-empty subarray from nums that has the maximum possible bitwise AND. In other words, let ... Topics: Array, Bit Manipulation, Brainteaser
- 2356. Largest Combination With Bitwise AND Greater Than Zero - Medium - Bit ManipulationThe bitwise AND of an array nums is the bitwise AND of all integers in nums. For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 ... Topics: Array, Hash Table, Bit Manipulation, Counting
- 3414. Find Number of Ways to Reach the K-th Stair - Hard - Bit ManipulationYou are given a non-negative integer k. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0. Alice has an int... Topics: Math, Dynamic Programming, Bit Manipulation, Memoization, Combinatorics
- 401. Binary Watch - Easy - Bit ManipulationA binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a ze... Topics: Backtracking, Bit Manipulation
- 1038. Number of Squareful Arrays - Hard - Bit ManipulationAn array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutation... Topics: Array, Hash Table, Math, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 3600. Find the K-th Character in String Game I - Easy - Bit ManipulationAlice and Bob are playing a game. Initially, Alice has a string word = "a". You are given a positive integer k. Now Bob will ask Alice to perform the ... Topics: Math, Bit Manipulation, Recursion, Simulation
- 491. Non-decreasing Subsequences - Medium - Bit ManipulationGiven an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may retu... Topics: Array, Hash Table, Backtracking, Bit Manipulation
- 3697. Minimum Increments for Target Multiples in an Array - Hard - Bit ManipulationYou are given two arrays, nums and target. In a single operation, you may increment any element of nums by 1. Return the minimum number of operations ... Topics: Array, Math, Dynamic Programming, Bit Manipulation, Number Theory, Bitmask
- 1557. Check If a String Contains All Binary Codes of Size K - Medium - Bit ManipulationGiven a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.... Topics: Hash Table, String, Bit Manipulation, Rolling Hash, Hash Function
- 1520. Number of Steps to Reduce a Number in Binary Representation to One - Medium - Bit ManipulationGiven the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules: If the current nu... Topics: String, Bit Manipulation, Simulation
- 2114. Minimum Number of Work Sessions to Finish the Tasks - Medium - Bit ManipulationThere are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to fi... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 757. Pyramid Transition Matrix - Medium - Bit ManipulationYou are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains one less block... Topics: Bit Manipulation, Depth-First Search, Breadth-First Search
- 2754. Maximum Strength of a Group - Medium - Bit ManipulationYou are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of stud... Topics: Array, Dynamic Programming, Backtracking, Greedy, Bit Manipulation, Sorting, Enumeration
- 2659. Number of Even and Odd Bits - Easy - Bit ManipulationYou are given a positive integer n. Let even denote the number of even indices in the binary representation of n with value 1. Let odd denote the numb... Topics: Bit Manipulation
- 2256. Count Words Obtained After Adding a Letter - Medium - Bit ManipulationYou are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only. For each string in t... Topics: Array, Hash Table, String, Bit Manipulation, Sorting
- 1473. Find the Longest Substring Containing Vowels in Even Counts - Medium - Bit ManipulationGiven the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must ... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 3560. Maximum Number of Moves to Kill All Pawns - Hard - Bit ManipulationThere is a 50 x 50 chessboard with one knight and some pawns on it. You are given two integers kx and ky where (kx, ky) denotes the position of the kn... Topics: Array, Math, Bit Manipulation, Breadth-First Search, Game Theory, Bitmask
- 672. Bulb Switcher II - Medium - Bit ManipulationThere is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a differ... Topics: Math, Bit Manipulation, Depth-First Search, Breadth-First Search
- 1645. Find a Value of a Mysterious Function Closest to Target - Hard - Bit ManipulationWinston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that m... Topics: Array, Binary Search, Bit Manipulation, Segment Tree
- 1435. XOR Queries of a Subarray - Medium - Bit ManipulationYou are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti]. For each query i compute the... Topics: Array, Bit Manipulation, Prefix Sum
- 2390. Naming a Company - Hard - Bit ManipulationYou are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company... Topics: Array, Hash Table, String, Bit Manipulation, Enumeration
- 1071. Binary Prefix Divisible By 5 - Easy - Bit ManipulationYou are given a binary array nums (0-indexed). We define xi as the number whose binary representation is the subarray nums[0..i] (from most-significan... Topics: Array, Bit Manipulation
- 1913. Make the XOR of All Segments Equal to Zero - Hard - Bit ManipulationYou are given an array nums and an integer k. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indic... Topics: Array, Dynamic Programming, Bit Manipulation
- 3875. Maximum Good Subtree Score - Hard - Bit ManipulationYou are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1. Each node i has an integer value vals[i], and its parent is g... Topics: Array, Dynamic Programming, Bit Manipulation, Tree, Depth-First Search, Bitmask
- 1553. Count Triplets That Can Form Two Arrays of Equal XOR - Medium - Bit ManipulationGiven an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). Let's define a and b as follows: a = ... Topics: Array, Hash Table, Math, Bit Manipulation, Prefix Sum
- 1662. Minimum Numbers of Function Calls to Make Target Array - Medium - Bit ManipulationYou are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following ... Topics: Array, Greedy, Bit Manipulation
- 3246. Check if Bitwise OR Has Trailing Zeros - Easy - Bit ManipulationYou are given an array of positive integers nums. You have to check if it is possible to select two or more elements in the array such that the bitwis... Topics: Array, Bit Manipulation
- 3431. Find the Minimum Cost Array Permutation - Hard - Bit ManipulationYou are given an array nums which is a permutation of [0, 1, 2, ..., n - 1]. The score of any permutation of [0, 1, 2, ..., n - 1] named perm is defin... Topics: Array, Dynamic Programming, Bit Manipulation, Bitmask
- 3713. Frequencies of Shortest Supersequences - Hard - Bit ManipulationYou are given an array of strings words. Find all shortest common supersequences (SCS) of words that are not permutations of each other. A shortest co... Topics: Array, String, Bit Manipulation, Graph, Topological Sort, Enumeration
- 2792. Neighboring Bitwise XOR - Medium - Bit ManipulationA 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n. Specifi... Topics: Array, Bit Manipulation
- 980. Find the Shortest Superstring - Hard - Bit ManipulationGiven an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of ... Topics: Array, String, Dynamic Programming, Bit Manipulation, Bitmask
- 2710. Minimum Operations to Reduce an Integer to 0 - Medium - Bit ManipulationYou are given a positive integer n, you can do the following operation any number of times: Add or subtract a power of 2 from n. Return the minimum nu... Topics: Dynamic Programming, Greedy, Bit Manipulation
- 2709. Count the Number of Square-Free Subsets - Medium - Bit ManipulationYou are given a positive integer 0-indexed array nums. A subset of the array nums is square-free if the product of its elements is a square-free integ... Topics: Array, Math, Dynamic Programming, Bit Manipulation, Bitmask
- 1873. Longest Nice Substring - Easy - Bit ManipulationA string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice beca... Topics: Hash Table, String, Divide and Conquer, Bit Manipulation, Sliding Window
- 1723. Maximum Number of Achievable Transfer Requests - Hard - Bit ManipulationWe have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the bui... Topics: Array, Backtracking, Bit Manipulation, Enumeration
- 3870. Minimum Moves to Clean the Classroom - Medium - Bit ManipulationYou are given an m x n grid classroom where a student volunteer is tasked with cleaning up litter scattered around the room. Each cell in the grid is ... Topics: Array, Hash Table, Bit Manipulation, Breadth-First Search, Matrix
- 3896. Minimum Time to Transport All Individuals - Hard - Bit ManipulationYou are given n individuals at a base camp who need to cross a river to reach a destination using a single boat. The boat can carry at most k people a... Topics: Array, Dynamic Programming, Bit Manipulation, Graph, Heap (Priority Queue), Shortest Path, Bitmask
- 2308. Divide Array Into Equal Pairs - Easy - Bit ManipulationYou are given an integer array nums consisting of 2 * n integers. You need to divide nums into n pairs such that: Each element belongs to exactly one ... Topics: Array, Hash Table, Bit Manipulation, Counting
- 3025. Minimum Operations to Form Subsequence With Target Sum - Hard - Bit ManipulationYou are given a 0-indexed array nums consisting of non-negative powers of 2, and an integer target. In one operation, you must apply the following cha... Topics: Array, Greedy, Bit Manipulation
- 1963. Find XOR Sum of All Pairs Bitwise AND - Hard - Bit ManipulationThe XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element. F... Topics: Array, Math, Bit Manipulation
- 477. Total Hamming Distance - Medium - Bit ManipulationThe Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given an integer array nums, retur... Topics: Array, Math, Bit Manipulation
- 1610. XOR Operation in an Array - Easy - Bit ManipulationYou are given an integer n and an integer start. Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length. Return the bitwi... Topics: Math, Bit Manipulation
- 3843. Partition Array into Two Equal Product Subsets - Medium - Bit ManipulationYou are given an integer array nums containing distinct positive integers and an integer target. Determine if you can partition nums into two non-empt... Topics: Array, Bit Manipulation, Recursion, Enumeration
- 1740. Count Subtrees With Max Distance Between Cities - Hard - Bit ManipulationThere are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between c... Topics: Dynamic Programming, Bit Manipulation, Tree, Enumeration, Bitmask
- 318. Maximum Product of Word Lengths - Medium - Bit ManipulationGiven a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such ... Topics: Array, String, Bit Manipulation
- 3826. Maximum Profit from Valid Topological Order in DAG - Hard - Bit ManipulationYou are given a Directed Acyclic Graph (DAG) with n nodes labeled from 0 to n - 1, represented by a 2D array edges, where edges[i] = [ui, vi] indicate... Topics: Array, Dynamic Programming, Bit Manipulation, Graph, Topological Sort, Bitmask
- 1381. Maximum Score Words Formed by Letters - Hard - Bit ManipulationGiven a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words f... Topics: Array, String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2594. Count Pairs Of Similar Strings - Easy - Bit ManipulationYou are given a 0-indexed string array words. Two strings are similar if they consist of the same characters. For example, "abca" and "cba" are simila... Topics: Array, Hash Table, String, Bit Manipulation, Counting
- 2059. Unique Length-3 Palindromic Subsequences - Medium - Bit ManipulationGiven a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to ob... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 2529. Range Product Queries of Powers - Medium - Bit ManipulationGiven a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is so... Topics: Array, Bit Manipulation, Prefix Sum
- 823. Split Array With Same Average - Hard - Bit ManipulationYou are given an integer array nums. You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and aver... Topics: Array, Math, Dynamic Programming, Bit Manipulation, Bitmask
- 3348. Minimum Cost Walk in Weighted Graph - Hard - Bit ManipulationThere is an undirected weighted graph with n vertices labeled from 0 to n - 1. You are given the integer n and an array edges, where edges[i] = [ui, v... Topics: Array, Bit Manipulation, Union Find, Graph
- 2427. First Letter to Appear Twice - Easy - Bit ManipulationGiven a string s consisting of lowercase English letters, return the first letter to appear twice. Note: A letter a appears twice before another lette... Topics: Hash Table, String, Bit Manipulation, Counting
- 1989. Minimum XOR Sum of Two Arrays - Hard - Bit ManipulationYou are given two integer arrays nums1 and nums2 of length n. The XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1... Topics: Array, Dynamic Programming, Bit Manipulation, Bitmask
- 693. Binary Number with Alternating Bits - Easy - Bit ManipulationGiven a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.... Topics: Bit Manipulation
- 3032. Maximize Value of Function in a Ball Passing Game - Hard - Bit ManipulationYou are given an integer array receiver of length n and an integer k. n players are playing a ball-passing game. You choose the starting player, i. Th... Topics: Array, Dynamic Programming, Bit Manipulation
- 1487. Cinema Seat Allocation - Medium - Bit ManipulationA cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. Given the ... Topics: Array, Hash Table, Greedy, Bit Manipulation
- 2478. Longest Nice Subarray - Medium - Bit ManipulationYou are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in ... Topics: Array, Bit Manipulation, Sliding Window
- 1632. Number of Good Ways to Split a String - Medium - Bit ManipulationYou are given a string s. A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to ... Topics: Hash Table, String, Dynamic Programming, Bit Manipulation
- 3453. Generate Binary Strings Without Adjacent Zeros - Medium - Bit ManipulationYou are given a positive integer n. A binary string x is valid if all substrings of x of length 2 contain at least one "1". Return all valid strings w... Topics: String, Backtracking, Bit Manipulation
- 2533. Bitwise XOR of All Pairings - Medium - Bit ManipulationYou are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. Let there be another array, nums3, which contains the bitwis... Topics: Array, Bit Manipulation, Brainteaser
- 1037. Minimum Number of K Consecutive Bit Flips - Hard - Bit ManipulationYou are given a binary array nums and an integer k. A k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in t... Topics: Array, Bit Manipulation, Queue, Sliding Window, Prefix Sum
- 828. Chalkboard XOR Game - Hard - Bit ManipulationYou are given an array of integers nums represents the numbers written on a chalkboard. Alice and Bob take turns erasing exactly one number from the c... Topics: Array, Math, Bit Manipulation, Brainteaser, Game Theory
- 2130. Maximum Product of the Length of Two Palindromic Subsequences - Medium - Bit ManipulationGiven a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoi... Topics: String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2498. Smallest Subarrays With Maximum Bitwise OR - Medium - Bit ManipulationYou are given a 0-indexed array nums of length n, consisting of non-negative integers. For each index i from 0 to n - 1, you must determine the size o... Topics: Array, Binary Search, Bit Manipulation, Sliding Window
- 1839. Decode XORed Array - Easy - Bit ManipulationThere is a hidden integer array arr that consists of n non-negative integers. It was encoded into another integer array encoded of length n - 1, such ... Topics: Array, Bit Manipulation
- 895. Shortest Path to Get All Keys - Hard - Bit ManipulationYou are given an m x n grid grid where: '.' is an empty cell. '#' is a wall. '@' is the starting point. Lowercase letters represent keys. Uppercase le... Topics: Array, Bit Manipulation, Breadth-First Search, Matrix
- 1418. Fair Distribution of Cookies - Medium - Bit ManipulationYou are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes th... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2400. Minimum Score After Removals on a Tree - Hard - Bit ManipulationThere is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given a 0-indexed integer array nums of length n w... Topics: Array, Bit Manipulation, Tree, Depth-First Search
- 1881. Closest Subsequence Sum - Hard - Bit ManipulationYou are given an integer array nums and an integer goal. You want to choose a subsequence of nums such that the sum of its elements is the closest pos... Topics: Array, Two Pointers, Dynamic Programming, Bit Manipulation, Sorting, Bitmask
- 1409. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix - Hard - Bit ManipulationGiven a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 t... Topics: Array, Hash Table, Bit Manipulation, Breadth-First Search, Matrix
- 2905. Count Paths That Can Form a Palindrome in a Tree - Hard - Bit ManipulationYou are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree... Topics: Dynamic Programming, Bit Manipulation, Tree, Depth-First Search, Bitmask
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems
- Divide and Conquer LeetCode Problems