# Bit Magic

### K-th smallest positive integer having sum with given number equal to bitwise OR with given number

Given two positive integers X and K, the task is to find the K-th smallest positive integer Y, such that…

### Lexicographically smallest binary string formed by flipping bits at indices not divisible K1 or K2 such that count of 1s is always greater than 0s from left

#include using namespace std;  void generateString(int k1, int k2, string s){            int C1s = 0, C0s = 0;    int flag = 0;    vector pos;          for…

### Kth smallest positive integer Y such that its sum with X is same as its bitwise OR with X

Given two positive integers X and K, the task is to find the Kth smallest positive integer (Y) such that…

### Check if it is possible to construct an Array of size N having sum as S and XOR value as X

Given three numbers N, S and X the task is to find if it is possible to construct a sequence…

### Sum of all subsets of a given size

Given an array arr[] consisting of N integers and a positive integer K, the task is to find the sum…

### Maximize XOR by selecting 3 numbers in range [0, A], [0, B], and [0, C] respectively

Given 3 integers A, B, C, the task is to find the maximum XOR value of three number selected one…

### Find Binary string by converting all 01 or 10 to 11 after M iterations

Given a binary string str[] of size N and an integer M. This binary string can be modified by flipping…

### Check if Decimal representation of given Binary String is divisible by K or not

Given a binary string S, the task is to find that the decimal representation of the given binary string is…