# Category Archives: Strings

Questions related to strings

## Length of the longest substring with equal 1s and 0sOctober 25, 2017

Given a binary string. We need to find the length of longest balanced sub string. A sub string is balanced if it contains equal number… Read More »

## Possibility of moving out of mazeOctober 24, 2017

Given n integers in a maze indicating number of moves to be made from that position and a string which has “>” and “<" indicating… Read More »

## Burrows – Wheeler Data Transform Algorithm

What is the Burrows – Wheeler Transform? The BWT is a data transformation algorithm that restructures data in such a way that the transformed message… Read More »

## Remove all consecutive duplicates from the stringOctober 23, 2017

Given a string S, remove all the consecutive duplicates. Note that this problem is different from Recursively remove all adjacent duplicates. Here we keep one… Read More »

## Minimum reduce operations to covert a given string into a palindromeOctober 21, 2017

Given a String find the minimum number of reduce operations required to convert a given string into a palindrome. In a reduce operation, we can… Read More »

## Reverse string in Python (5 different ways)

Python string library does’nt support the in-built “reverse()” as done by other python containers like list, hence knowing other methods to reverse string can prove… Read More »

## Simplify the directory path (Unix like)October 20, 2017

Given an absolute path for a file (Unix-style), simplify it. Note that absolute path always begin with ‘/’ ( root directory ), a dot in… Read More »

## Length of Longest Balanced SubsequenceOctober 19, 2017

Given a string S, find the length of longest balanced subsequence in it. A balanced string is defined as:- A Null string is a balanced… Read More »

## Common characters in n strings

Given n strings, find the common characters in all the strings. In simple words, find characters that appear in all the strings and display them… Read More »

## Lexicographically smallest string whose hamming distance from given string is exactly KOctober 17, 2017

Given a lowercase string A of length N and an integer K, find the lexicographically smallest string B of the same length as A such… Read More »

## Count of strings where adjacent characters are of difference oneOctober 16, 2017

iven a number n, count number of strings of length n such that every string has adjacent characters with difference between ASCII values as 1.… Read More »

## stringstream in C++ and its applications

A stringstream associates a string object with a stream allowing you to read from the string as if it were a stream (like cin). Basic… Read More »

## Lexicographically largest subsequence such that every character occurs at least k timesOctober 14, 2017

Given a string S and an integer K. The task is to find lexicographically largest subsequence of S, say T, such that every character in… Read More »

## Shortest substring of a string containing all given wordsOctober 11, 2017

Print the shortest sub-string of a string containing all the given words. In the first example, two solutions are possible: “world is here. this is… Read More »

## Minimal operations to make a number magical

Given a 6 digit number, calculate the minimum number of digits that needs to be replaced in order to make the number magical. The number… Read More »