Bit-Manipulation
LeetCode 3750: Minimum Number of Flips to Reverse Binary String
·2 mins
LeetCode
Easy
Two-Pointers
Bit-Manipulation
String
LeetCode 3750 note: compare the binary string with its reverse bit by bit; the number of mismatches is the answer
LeetCode 3688: Bitwise OR of Even Numbers in an Array
·1 min
LeetCode
Easy
Bit-Manipulation
Array
Simulation
LeetCode 3688 note: OR only the even numbers; the starting value 0 is also the answer when there are none
LeetCode 3644: Maximum K to Sort a Permutation
·2 mins
LeetCode
Medium
Bit-Manipulation
Array
LeetCode 3644 note: every misplaced number must be swapped, so each bit of k must belong to all of them; the answer is the AND of every misplaced number
LeetCode 2044: Count Number of Maximum Bitwise-OR Subsets
·2 mins
LeetCode
Medium
Backtracking
Bit-Manipulation
Enumeration
LeetCode 2044 note: the maximum OR is the OR of everything; once backtracking reaches it, count the rest as 2^k
LeetCode 1290: Convert Binary Number in a Linked List to Integer
·2 mins
LeetCode
Easy
Linked-List
Bit-Manipulation
Math
LeetCode 1290 note: walk head to tail, shifting the running value left by one and adding the new bit
LeetCode 3513: Number of Unique XOR Triplets I
·2 mins
LeetCode
Biweekly-Contest
Medium
Bit-Manipulation
Unsolved
LeetCode Problem Solving
LeetCode 2859: Sum of Values at Indices With K Set Bits
·1 min
LeetCode
Easy
Array
Bit-Manipulation
LeetCode 2859 note: count the set bits of the index, not of the value
LeetCode 222: Count Complete Tree Nodes
·2 mins
LeetCode
Medium
Binary-Search
Bit-Manipulation
Tree
Binary-Tree
LeetCode 222 note: in a complete tree, equal leftmost depths on both sides mean one side is perfect, counted as 2^h - 1, for O(log² n)
LeetCode 473: Matchsticks to Square
·2 mins
LeetCode
Medium
Array
Dynamic-Programming
Backtracking
Bit-Manipulation
LeetCode 473 note: the total must be divisible by 4; place sticks from longest to shortest into one of four sides, skipping a side that would overflow or that equals a side already tried
LeetCode 397: Integer Replacement
·2 mins
LeetCode
Medium
Dynamic-Programming
Greedy
Bit-Manipulation
Memoization
LeetCode 397 note: even numbers are always halved; for odd numbers try +1 and -1 with memoized recursion, since n is too large for an n-sized array
LeetCode 338: Counting Bits
·2 mins
LeetCode
Easy
Dynamic-Programming
Bit-Manipulation
LeetCode 338 note: dp[i] = dp[i » 1] + (i & 1), or dp[i] = dp[i - highest power of two] + 1
LeetCode 187: Repeated DNA Sequences
·1 min
LeetCode
Medium
Hash-Table
String
Bit-Manipulation
Sliding-Window
LeetCode 187 note: count every length-10 substring in a hash map and return those seen more than once