# Category Archives: Strings

Questions related to strings

## Transform One String to Another using Minimum Number of Given OperationAugust 19, 2015

Given two strings A and B, the task is to convert A to B if possible. The only operation allowed is to put any character… Read More »

## Shortest Superstring ProblemJuly 4, 2015

Given a set of n strings arr[], find the smallest string that contains each string in the given set as substring. We may assume that… Read More »

## Recursive function to do substring searchJune 27, 2015

Given a text txt[] and a pattern pat[], write a recursive function “contains(char pat[], char txt[])” that returns true if pat[] is present in txt[],… Read More »

## Remove spaces from a given stringJune 18, 2015

Given a string, remove all spaces from the string and return it. Input: “g eeks for ge eeks ” Output: “geeksforgeeks”

## Online algorithm for checking palindrome in a streamMay 14, 2015

Given a stream of characters (characters are received one by one), write a function that prints ‘Yes’ if a character makes the complete string palindrome,… Read More »

## Recursively print all sentences that can be formed from list of word listsApril 12, 2015

Given a list of word lists How to print all sentences possible taking one word from a list at a time via recursion?

## Check if a given sequence of moves for a robot is circular or notMarch 25, 2015

Given a sequence of moves for a robot, check if the sequence is circular or not. A sequence of moves is circular if first and… Read More »

## Find the longest substring with k unique characters in a given stringMarch 18, 2015

Given a string you need to print longest possible substring that has exactly M unique characters. If there are more than one substring of longest… Read More »

## Function to find Number of customers who could not get a computerMarch 3, 2015

Write a function “runCustomerSimulation” that takes following two inputs a) An integer ‘n’: total number of computers in a cafe and a string: b) A… Read More »

## Find maximum depth of nested parenthesis in a stringFebruary 26, 2015

We are given a string having parenthesis like below      “( ((X)) (((Y))) )” We need to find the maximum depth of balanced parenthesis, like… Read More »

## Find all distinct palindromic sub-strings of a given stringFebruary 12, 2015

Given a string of lowercase ASCII characters, find all distinct continuous palindromic sub-strings of it.

## Find if a given string can be represented from a substring by iterating the substring “n” timesJanuary 12, 2015

Given a string ‘str’, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.

## Print all possible strings that can be made by placing spacesDecember 21, 2014

Given a string you need to print all possible strings that can be made by placing spaces (zero or one) in between them.

## Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 4December 20, 2014

In Manacher’s Algorithm Part 1 and Part 2, we gone through some of the basics, understood LPS length array and how to calculate it efficiently… Read More »

## Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 3December 17, 2014

In Manacher’s Algorithm Part 1 and Part 2, we gone through some of the basics, understood LPS length array and how to calculate it efficiently… Read More »