# Tag Archives: binary-string

## Rearrange a binary string as alternate x and y occurrencesOctober 10, 2017

Given a binary string s and two integers x and y are given. Task is to arrange the given string in such a way so… Read More »

## Count of substrings of a binary string containing K onesOctober 8, 2017

Given a binary string of length N and an integer K, we need to find out how many substrings of this string are exist which… Read More »

## Print N-bit binary numbers having more 1’s than 0’s in all prefixesOctober 4, 2017

Given a positive integer n, print all n-bit binary numbers having more 1’s than 0’s for any prefix of the number. Examples: Input : n… Read More »

## Sort a binary array using one traversalSeptember 26, 2017

Given a binary array, sort it using one traversal and no extra space. Examples: Input : 1 0 0 1 0 1 0 1 1… Read More »

## Binary representation of previous numberSeptember 13, 2017

Given a binary input that represents binary representation of positive number n, find binary representation of n-1. It may be assumed that input binary number… Read More »

## All possible binary numbers of length n with equal sum in both halvesSeptember 8, 2017

Given a number n, we need to print all n-digit binary numbers with equal sum in left and right halves. If n is odd, then… Read More »

## Binary array after M range toggle operationsSeptember 5, 2017

Consider a binary array consisting of N elements (initially all elements are 0). After that you are given M commands where each command is of… Read More »

## Longest common substring in binary representation of two numbersAugust 5, 2017

Given two integers n and m. Find the longest contiguous subset in binary representation of both the numbers and its decimal value. Example 1: Input… Read More »

## Count of occurrences of a “1(0+)1” pattern in a stringJuly 31, 2017

Given an alphanumeric string, find the number of times a pattern 1(0+)1 occurs in the given string. Here, (0+) signifies the presence of non empty… Read More »

## Ways to remove one element from a binary string so that XOR becomes zeroJuly 19, 2017

Given a binary string, task is to erase exactly one integer in the array so that the XOR of the remaining numbers is zero. The… Read More »

## Find the index of first 1 in a sorted array of 0’s and 1’sJuly 13, 2017

Given a sorted array consisting 0’s and 1’s. The problem is to find the index of first ‘1’ in the sorted array. It could be… Read More »

## Min flips of continuous characters to make all characters same in a stringJuly 12, 2017

Given a string consisting only of 1’s and 0’s. In one flip we can change any continuous sequence of this string. Find this minimum number… Read More »

## Queries for decimal values of subarrays of a binary arrayJuly 3, 2017

Given a binary array arr[], we to find the number represented by the subarray a[l..r]. There are multiple such queries. Examples: Input : arr[] =… Read More »

## Check if a binary string has a 0 between 1s or not | Set 2 (Regular Expression Approach)

Given a string of 0 and 1, we need to check that the given string is valid or not. The given string is valid when… Read More »

## Check if a binary string has a 0 between 1s or not | Set 1 (General approach)June 26, 2017

Given a string of 0 and 1, we need to check that the given string is valid or not. The given string is valid when… Read More »