## Bitwise and of number range

You are given a number range, you need to find the bitwise and of all the numbers in the range. Example: The bitwise and of 5, 6, 7 will be 4. The solution is very simple, once you understand the concept below: …

Tutorials and Programming Solutions

You are given a number range, you need to find the bitwise and of all the numbers in the range. Example: The bitwise and of 5, 6, 7 will be 4. The solution is very simple, once you understand the concept below: …

You are given 2 integers, and you need to return the count at which the bits are different in their binary form. Consider 8 and 1 As highlighted in the image, there are 2 positions where the bits are different. Hence output should be …

You are given a number; you need to create an array to fill the number of 1’s present in their binary format. Example: Input n = 3 Output = Because for 0, the number of set bits is 0. For 1, it’s binary …

Problem statement: You are given an array of numbers from 1 to n, in any order, one number will be missing. You need to find a missing number. Example: Input: Output: 2 We can solve this problem by 2 methods: Finding the …

Given a number, you need to check if the number is a power of 2, return true or false accordingly. Example: Input: 1 Output: True Because 2^0 is 1 Input: 15 Output: False Because 15 is not a power of 2. …

Problem statement: You are given a number, return the number of set bits if that number, when represented that number in binary format. Example: If the input number is 10, it’s binary representation is 1010. The number of set bits are 2. This problem …

Problem Statement: You are given a number as input. You need to reverse the bits in it’s binary form and print the output. The maximum length is a 32-bit unsigned integer. Example: Let’s see how to solve this problem Let us take …

In this tutorial we shall see how to print all the nodes that is k distance from root. Problem statement: Given the root node and the distance k, print all the nodes that are at distance k from root node. Consider the image below: …

In this chapter we shall see how to print all the paths from root to leaf nodes. Problem Statement: You are given the root node of a binary tree, you need to print all the paths from root node to leaf nodes. Consider the example …

In this chapter we shall print the number of leaf nodes in a binary tree. Problem Statement: You are given the root node of the tree. You need to return the total number of leaf nodes present in that tree. Example: Consider the …