## Sorting array with conditional swapping

Given an array arr containing elements from [1…to n]. Each element appears exactly once in the array arr. Given an string str of length n-1.… Read More »

Given an array arr containing elements from [1…to n]. Each element appears exactly once in the array arr. Given an string str of length n-1.… Read More »

We are given an integer N. We need to count the total number of such binary strings of length N such that the number of… Read More »

There are n student groups at the school. On each day in school, there are m time slots. A student group may or may not… Read More »

Given a binary string and a number k, task is to check whether the binary string is evenly divisible by 2k or not. Examples :… Read More »

Dragon Curve Sequence is an infinite binary sequence of 0s and 1s. The first term of the sequence is 1. From the next term, we… Read More »

Thue–Morse sequence, or Prouhet–Thue–Morse sequence, is an infinite binary sequence of 0s and 1s. The sequence is obtained by starting with 0 and successively appending… Read More »

Given n and k, Construct a palindrome of size n using a binary number of size k repeating itself to wrap into the palindrome. The… Read More »

Given a binary array, task is to sort this binary array. Examples : Input : [0, 0, 1, 0, 1, 0, 1, 1] Output :… Read More »

Given a string of character the task is to convert each character of a string into the equivalent binary number. Examples : Input : GFG… Read More »

Given an array A of size N consisting of elements 1 to N. A boolean array B consisting of N-1 elements indicates that if B[i]… Read More »

Given a decimal number m, convert it into a binary string and apply n iterations, in each iteration 0 becomes “01” and 1 becomes “10”.… Read More »

Given a binary string of 0s and 1s. The task is to find the length of substring which is having a maximum difference of number… Read More »

Given a binary string of size N. Count all substring that have even decimal value considering binary to decimal conversion from left to right (For… Read More »

Given K and a binary number, check if there exists k consecutive 1’s in the binary number. Examples: Input : binary number = 101010101111 k… Read More »

Given a binary string containing only 0’s and 1’s. Write a program to find number of sub-strings of this string whose decimal representation is odd.… Read More »