Tag Archives: CPP-bitset

Given a range of integers, the task is to find the numbers of Non-Negative Integers which doesn’t contain consecutive ones (1s) in their binary representation.… Read More
Bit stands for binary digit. A bit is the basic unit of information and can only have one of two possible values that is 0… Read More
Let’s implement bitset in C++, such that following operations can be performed in stated time complexities : init(int size): initializes a bitset of size number… Read More
A bitset is an array of boolean values, but each boolean value is not stored separately. Instead, bitset optimizes the space such that each bool… Read More
Given a Directed Acyclic Graph with V vertices and E edges, the task is to find the set of dominant vertices for each vertex of… Read More
Given an array arr[] consisting of N integers, and an integer K, the task is to construct a binary string of length K satisfying the… Read More
Given an array arr[] consisting of N integers an array Q[][] consisting of queries of the form {l, r}. For each query {l, r}, the… Read More
Give binary string str and an integer N, the task is to check if the substrings of the string contain all binary representations of non-negative… Read More
The _Find_first() is a built-in function in C++ Bitset class which returns an integer that refers the position of first set bit in bitset. If… Read More
The _Find_next() is a built-in function in C++ Bitset class which returns an integer which refers the position of next set bit in bitset after… Read More
Given a large binary number.The task is to count the number of 1’s in a given range from L to R (1 based indexing).Examples:  Input… Read More
Given two arrays a[] and b[], the task is to find the count of common elements in both the given arrays. Note that both the… Read More
Given two unsigned integers (maximum possible input can be of 32 bits). The task is to add two numbers using bit operations.  Examples:   Input: n1… Read More
bitset::test() is an inbuilt function in C++ STL which tests whether the bit at a given index is set or not.  Syntax: bitset_name.test(index) Parameters: The… Read More
bitset::set() is a built-in STL in C++ which sets the bit to a given value at a particular index. If no parameter is passed, it… Read More