ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Print the numbers without consecutive 1s in binary representation Problem Statement: You are given a number “N”. You need to print all the numbers with no consecutive 1s in binary representation…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Perform multiplication operation using Bitwise operators 1. Multiply a number with 2 ^n 2. Check if a number is power of 4 or not 1. Multiply a number with 2 ^n The solution is very simple. We know…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Perform below swapping operations using Bitwise operators 1. Swap 2 nibble 2. Swap all even and odd bits 3. Swapping pair of bits in a Byte 1. Swap 2 nibble (num & 0x0F)<<4 | (num &…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Perform below operations using Bitwise Operators 1. Get the value of nth bit 2. Set the value of nth bit 3. Clear the value of nth bit 4. Toggle the nth bit 5. Get the total number of set…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Given 2 numbers check if one number is complement of another and also check if those two numbers are same using bitwise operators Check if one number is a complement of another: One’s complement of a number is obtained by inverting all the bits. Example: num_1 = 10 num_2…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Check if the number has bits in alternate pattern and also check if the same number has equal number of set and unset bits using bitwise operators Check if the number has bits in alternate pattern The solution contains 3 steps: 1. Right shift the number by 1 2. XOR the above result with…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Calculate the square of a number and also check if that number is even or odd using bitwise operator. Calculate the square of a number using bitwise operator. Truth table of binary multiplication is below: 0 x 0 = 0 0 x 1 = 0 1 x 0 = 0 1 x 1 =…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Add and subtract 2 numbers using bitwise operators. We can solve this by using bit manipulation. Addition using bitwise operators: XOR (^) operation will give us addition of 2 bits. Carry bit…
ProDeveloperTutorialonAugust 7, 2026 Bitwise Operators: Given a binary number, return the 1’s and 2’s complement of that number Before getting into programming, we shall look at how to get 1’s and 2’s complement of a given binary number. 1’s Complement: 1’s complement…
ProDeveloperTutorialonAugust 7, 2026 Arrays: Implement prefix sum array Problem Statement: You are given an array, you need to find the prefix sum of the array. Prefix sum array is a new array of same size of…