# Bit Magic

### Count of subsequences with sum two less than the array sum

Given an array vec[] of size N of non-negative integers. The task is to count the number of subsequences with…

### Maximize 0s to be flipped in given Binary array such that there are at least K 0s between two 1s

Given a binary array arr[] and an integer K, the task is to count the maximum number of 0’s that…

### Count of Binary Strings of length at most N with set bit count as multiple of K

Given two integers N and K, the task is to find the count of binary strings of at most N…

### Minimum operations to convert Binary Matrix A to B by flipping submatrix of size K

#include using namespace std;  int minMoves(vector a,             vector b,             int K){        int n = a.size(), m = a[0].size();            int cntOperations = 0;          for (int i =…

### Check if there are T number of continuous of blocks of 0s or not in given Binary Matrix

#include using namespace std;const long long M = 1e9 + 7;  vector directions    = { { 0, 1 }, { -1, 0…

### Check if count of 1s can be made greater in a Binary string by changing 0s adjacent to 1s

Given a binary string S of size N, the task is to check if the count of 1s can be…

### 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…