Bitwise Algorithms | Intermediate

Last Updated : 26 Sep, 2023

 

  1. Swap bits in a given number
  2. Little and Big Endian Mystery
  3. Smallest of three integers without comparison operators
  4. A Boolean Array Puzzle
  5. Compute the integer absolute value (abs) without branching
  6. Compute the minimum or maximum of two integers without branching
  7. Find the two non-repeating elements in an array of repeating elements
  8. Write an Efficient C Program to Reverse Bits of a Number
  9. Smallest power of 2 greater than or equal to n
  10. Write a C program to find the parity of an unsigned integer
  11. Swap all odd and even bits
  12. Check if binary representation of a number is palindrome
  13. Generate n-bit Gray Codes
  14. Check if a given number is sparse or not
  15. Euclid’s Algorithm when % and / operations are costly
  16. Find nth Magic Number
  17. How to swap two bits in a given integer?
  18. Calculate square of a number without using *, / and pow()
  19. Generate 0 and 1 with 25% and 75% probability
  20. Find even occurring elements in an array of limited range
  21. Cyclic Redundancy Check and Modulo-2 Division
  22. Copy set bits in a range
  23. Check if a number is Bleak
  24. Count strings with consecutive 1’s
  25. Gray to Binary and Binary to Gray conversion
  26. Find Next Sparse Number
  27. Sum of bit differences among all pairs
  28. Sum of Bitwise And of all pairs in a given array
  29. Bitwise and (or &) of a range
  30. Length of the Longest Consecutive 1s in Binary Representation
  31. Pairs of complete strings in two sets of strings
  32. Find profession in a special family
  33. Print first n numbers with exactly two set bits
  34. Check if bits of a number has count of consecutive set bits in increasing order
  35. Subset sum queries using bitset
  36. Maximum 0’s between two immediate 1’s in binary representation
  37. Count all pairs of an array which differ in K bits
  38. Efficiently check if a string has duplicates without using any additional data structure
  39. Count trailing zero bits using lookup table
  40. Count smaller numbers whose XOR with n produces greater value
  41. Check divisibility in a binary stream
  42. Multiplication of two numbers with shift operator
  43. Determine if a string has all Unique Characters
  44. Reverse an array without using subtract sign ‘-‘ anywhere in the code
  45. Count numbers whose sum with x is equal to XOR with x
  46. Maximum XOR value of a pair from a range
  47. Numbers whose bitwise OR and sum with N are equal
  48. Change bits to make specific OR value
  49. Count smaller values whose XOR with x is greater than x
  50. Next greater integer having one more number of set bits
  51. Check if two numbers are bit rotations of each other or not
  52. Previous smaller integer having one less number of set bits
  53. Maximize a given unsigned number number by swapping bits at it’s extreme positions
  54. Set bits in N equals to M in the given range
  55. Count number of distinct sum subsets within given range
  56. Baum Sweet Sequence
  57. Minimum digits to remove to make a number Perfect Square
  58. Number whose sum of XOR with given array range is maximum
  59. Odd numbers in N-th row of Pascal’s Triangle
  60. Check if bitwise AND of any subset is power of two
  61. Space optimization using bit manipulations
  62. Fast inverse square root
  63. Find one extra character in a string
  64. Number of unique triplets whose XOR is zero
  65. Fibbinary Numbers (No consecutive 1s in binary)
  66. Fibbinary Numbers (No consecutive 1s in binary) – O(1) Approach
  67. Divide two integers without using multiplication, division and mod operator
  68. Check if binary string multiple of 3 using DFA
  69. Count set bits in an integer using Lookup Table
  70. Alternate bits of two numbers to create a new number
  71. Decimal representation of given binary string is divisible by 20 or not
  72. Check if actual binary representation of a number is palindrome
  73. Reverse actual bits of the given number
  74. Odious number
  75. Pernicious number
  76. Increment a number by one by manipulating the bits
  77. Python Slicing | Extract ‘k’ bits from a given position
  78. Print numbers in the range 1 to n having bits in alternate pattern
  79. Python | Count unset bits in a range
  80. Addition of two numbers without carry
  81. Josephus Problem Using Bit Magic
  82. XNOR of two numbers
  83. Maximum OR sum of sub-arrays of two different arrays
  84. Position of rightmost bit with first carry in sum of two binary
  85. Check whether the two numbers differ at one bit position only
  86. Queries on XOR of XORs of all subarrays
  87. Count unset bits in a range
  88. A backtracking approach to generate n bit Gray Codes
  89. Quotient and remainder dividing by 2^k (a power of 2)
  90. Print pair with maximum AND value in an array
  91. Smallest perfect power of 2 greater than n (without using arithmetic operators)
  92. Reverse bits using lookup table in O(1) time
  93. Variation in Nim Game
  94. Find largest element from array without using conditional operator
  95. Unset the last m bits
  96. Check if a number is divisible by 17 using bitwise operators
  97. Bitwise Sieve
  98. Largest number with binary representation is m 1’s and m-1 0’s
  99. Maximum AND value of a pair in an array
  100. Smallest number whose set bits are maximum in a given range
  101. Minimum flips to make all 1s in left and 0s in right | Set 1 (Using Bitmask)
  102. Find two numbers from their sum and XOR
  103. Print all subsequences of a string | Iterative Method
  104. Divisibility by 64 with removal of bits allowed
  105. Count set bits in a range
  106. Unique element in an array where all elements occur k times except one
  107. Find Unique pair in an array with pairs of numbers
  108. Check whether the number has only first and last bits set
  109. M-th smallest number having k number of set bits.
  110. Minimum bitwise operations to convert given a into b
  111. Minimum flips required to maximize a number with k set bits
  112. Count unset bits of a number
  113. Check whether all the bits are unset in the given range or not
  114. Toggle all bits after most significant bit
  115. Check if a number is power of 8 or not
  116. Position of rightmost common bit in two numbers
  117. Check whether all the bits are set in the given range
  118. Shuffle a pack of cards and answer the query
  119. Efficiently find first repeated character in a string without using any additional data structure in one traversal
  120. Change all even bits in a number to 0
  121. Computing INT_MAX and INT_MIN with Bitwise operations
  122. Add minimum number to an array so that the sum becomes even
  123. Get the position of rightmost unset bit
  124. Count pairs with Odd XOR
  125. Position of rightmost different bit
  126. Check if all bits of a number are set
  127. XOR of all subarray XORs | Set 2
  128. Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
  129. Highest power of 2 less than or equal to given number
  130. Find Two Missing Numbers | Set 2 (XOR based solution)
  131. Find the maximum subset XOR of a given set

Quick Links :

If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.



Share your thoughts in the comments

Similar Reads