#include using namespace std;void findTotalDistance(string S, int N){ vector prefixDistance(N); vector suffixDistance(N); int cnt = 0; bool haveOne = false; for (int i = 0;…

# binary-string

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

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

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

### Count of substrings in a Binary String that contains more 1s than 0s

#include using namespace std; void merge(vector& v, int left, int mid, int right, int& inversions){ vector temp(right – left + 1); int i =…

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

### Maximum count of “010..” subsequences that can be removed from given Binary String

Maximum count of “010..” subsequences that can be removed from given Binary StringGiven a binary string S consisting of size…

### Minimize hamming distance in Binary String by setting only one K size substring bits

Minimize hamming distance in Binary String by setting only one K size substring bits Given two binary strings S and…

### Minimize cost to make all characters of a Binary String equal to ‘1’ by reversing or flipping characters of substrings

Minimize cost to make all characters of a Binary String equal to ‘1’ by reversing or flipping characters of substringsGiven…

### Largest Prime Number possible from a subsequence of a Binary String

#include #include using namespace std; bool isPrime(int x){ if (x