avatar_url

Sandesh Rana | Python

I'm a developer from Himalayas, with a passion for crafting efficient and elegant code, with creativity and precision.

Bit manipulation

21 Aug 2024 » programming, algorithm

Bit Manipulation: Easy to Hard Problems

Easy

  1. Single Number (Finds the single number in an array where every other number appears twice)
  2. Number of 1 Bits (Counts the number of 1 bits in a binary representation of a number)
  3. Power of Two (Checks if a number is a power of two)
  4. Reverse Bits (Reverses the bits of a 32-bit unsigned integer)
  5. Hamming Distance (Calculates the Hamming distance between two integers)
  6. Missing Number (Finds the missing number in a range using XOR)
  7. Single Number II (Finds the single number that appears once when others appear thrice)
  8. Find the Duplicate Number *(Finds the duplicate number in an array using bit manipulation

Medium (continued)

  1. Find the Duplicate Number (Finds the duplicate number in an array using bit manipulation)
  2. Bitwise AND of Numbers Range (Finds the bitwise AND of numbers in a given range)
  3. Total Hamming Distance (Calculates the total Hamming distance between all pairs of numbers in an array)

Hard

  1. Maximum XOR of Two Numbers in an Array (Finds the maximum XOR of any two numbers in an array)
  2. Find Minimum XOR Sum of Two Arrays (Finds the minimum XOR sum of two arrays by pairing elements)
  3. Subsets with Bit Manipulation (Generates all possible subsets using bit manipulation)
  4. Longest Substring with At Most Two Distinct Characters (Finds the longest substring with at most two distinct characters using bit manipulation)
  5. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix (Finds the minimum number of flips required to convert a binary matrix to a zero matrix)