Bitwise
13 snippets
Bit Counting
Counts the set bits in the binary representation of an integer
Check Power of Two
Checks if a given number is a power of two using bitwise operations.
Clear ith bit
Clear the ith bit of a number and returns the resulting number
Count Set Bits
Counts the number of set bits in an int
Find Non-Repeating Number
Finds the number that appears only once in an array where every other number appears twice.
Get ith bit
Get the i-th bit of a number
Is Odd
Check if a number is odd
Is Power Of Two
Checks if a number is a power of two
Reverse Bits
Reverses the bits of a given unsigned integer.
Set ith bit
Set the i-th bit of a number and returns the resulting number
Swap Numbers
Swap two numbers without a temporary variable
Toggle ith bit
Toggle the i-th bit of a number and returns the resulting number
XOR of Range
Finds XOR of all numbers from 1 to n using properties of XOR.