## Check if a string follows a^nb^n pattern or not

Given a string str, return true string follows pattern anbn, i.e., it has a’s followed by b’s such that the number of a’s and b’s… Read More »

## Minimum toggles to partition a binary array so that it has first 0s then 1s

Given an array of n integers containing only 0 and 1. Find the minimum toggles (switch from 0 to 1 or vice-versa) required such the… Read More »

## Count passing car pairs

A non-empty binary array A consisting of size N is given where, 0 represents a car traveling east, 1 represents a car traveling west. The… Read More »

## Maximum consecutive one’s (or zeros) in a binary array

Given binary array, find count of maximum number of consecutive 1’s present in the array. Examples : Input : arr[] = {1, 1, 0, 0,… Read More »

## Count binary strings with k times appearing adjacent two set bits

Given two integers n and k, count the number of binary strings of length n with k as number of times adjacent 1’s appear. Examples:… Read More »

## Efficient method for 2’s complement of a binary string

Given a Binary Number as string, print its 2’s complements. 2’s complement of a binary number is 1 added to the 1’s complement of the… Read More »

## Number of flips to make binary string alternate | Set 1

Given a binary string, that is it contains only 0s and 1s. We need to make this string a sequence of alternate characters by flipping… Read More »

## Length of Longest sub-string that can be removed

Given a binary string (consists of only 0 and 1). If there is “100” as a sub-string in the string, then we can delete this… Read More »

## Check if all bits can be made same by single flip

Given a binary string, find if it is possible to make all its digits equal (either all 0’s or all 1’s) by flipping exactly one… Read More »

## Find all even length binary sequences with same sum of first and second half bits

Given a number n, find all binary sequences of length 2n such that sum of first n bits is same as sum of last n… Read More »

## Generate all binary strings from given pattern

Given a string containing of ‘0’, ‘1’ and ‘?’ wildcard characters, generate all binary strings that can be formed by replacing each wildcard character by… Read More »

## Minimum number of palindromic subsequences to be removed to empty a binary string

Given a binary string, count minimum number of subsequences to be removed to make it an empty string. Examples : Input: str[] = “10001” Output:… Read More »

## Count strings with consecutive 1’s

Given a number n, count number of n length strings with consecutive 1’s in them. Examples: Input : n = 2 Output : 1 There… Read More »

## Longest Span with same Sum in two Binary arrays

Given two binary arrays arr1[] and arr2[] of same size n. Find length of the longest common span (i, j) where j >= i such… Read More »

## Given a binary string, count number of substrings that start and end with 1.

Given a binary string, count number of substrings that start and end with 1. For example, if the input string is “00100101”, then there are… Read More »