# Category Archives: Bit Magic

Two players, Player 1 and Player 2, are given an integer N to play a game. The rules of the game are as follows : … Read More
Given a binary string str, the task is to find the minimum operations required to convert the binary string in a non-decreasing manner such that… Read More
Given a binary array A[] and an integer X, the task is to check whether it is possible to divide A[] into exactly X non-empty… Read More
Given a positive integer n, write a function to find if it is a power of 2 or not Examples: Input: n = 4 Output:… Read More
Given two variables, x, and y, swap two variables without using a third variable. Method 1 (Using Arithmetic Operators): Example 1: The idea is to… Read More
Given an array A[] of size N (0 ≤ A[i] ≤ 109). The following operations can be performed on the array. Choose a random integer… Read More
Given a string S (‘a’ ≤ S[i] ≤ ‘t’) of length N (1 ≤ N ≤ 105), which consists of lowercase English alphabets, the task… Read More
Given a graph and the list of neighbours for each node in an array graph[] of size N, where graph[i] contains a list of neighbor… Read More
Given a string S of length N (1 ≤ N ≤ 103) that consists of a digit from ‘0’ to ‘9’, the task is to… Read More
Given a binary string S of a number N, the task is to find a number X such that we can minimize the value of… 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
Given an array arr[] of length N. You can perform at most K operations on the array of the following type:  Choose an index i… Read More
In a party of N people, each person is denoted by an integer. Couples are represented by the same number. Find out the only single… Read More
Given an array A[] consisting of N elements, the task is to find the minimum length of the subarray starting from each index and the… Read More
Given two integers X and S, the task is to find the minimum length of the sequence of positive integers such that the sum of… Read More