Category Archives: Strings

Questions related to strings

Check if two strings are k-anagrams or notJanuary 14, 2017

Given two strings of lowercase alphabets and a value k, the task is to find if two strings are K-anagrams of each other or not.… Read More »

Check if all rows of a matrix are circular rotations of each other

Given a matrix of n*n size, the task is to find whether all rows are circular rotations of each other or not. Input: mat[][] =… Read More »

Minimum number of characters to be removed to make a binary string alternateJanuary 12, 2017

Given a binary string, the task is to find minimum number of characters to be removed from it so that it becomes alternate. A binary… Read More »

Count of character pairs at same distance as in English alphabetsJanuary 11, 2017

Given a string, the task is to count the number of pairs whose elements are at same distances as in the English alphabets. Note :… Read More »

Print all palindromic partitions of a stringJanuary 6, 2017

Given a string s, partition s such that every string of the partition is a palindrome. Return all possible palindrome partitioning of s. Example :… Read More »

Minimum cost to sort strings using reversal operations of different costsJanuary 1, 2017

Given an array of strings and costs of reversing all strings, we need to sort the array. We cannot move strings in array, only string… Read More »

Word Break Problem using Backtracking

Given a valid sentence without any spaces between the words and a dictionary of valid English words, find all possible ways to break the sentence… Read More »

Nth character in Concatenated Decimal StringDecember 27, 2016

If all decimal numbers are concatenated in a string then we will get a string which looks like string P as shown below. We need… Read More »

Convert to a string that is repetition of a substring of k lengthDecember 20, 2016

Given a string, find if it is possible to convert it to a string that is repetition of substring with k characters. To convert, we… Read More »

Minimum characters to be added at front to make string palindromeDecember 18, 2016

Given a string str we need to tell minimum characters to be added at front of string to make string palindrome. Examples: Input : str… Read More »

Count All Palindrome Sub-Strings in a String | Set 1December 13, 2016

Given a string, the task is to count all palindrome substring in a given string. Length of palindrome substring is greater then or equal to… Read More »

Check for Palindrome after every character replacement QueryDecember 10, 2016

Given a string str and Q queries. Each query contains a pair of integers (i1, i2) and a character ‘ch’. We need to replace characters… Read More »

Group all occurrences of characters according to first appearanceDecember 9, 2016

Given a string of lowercase characters, the task is to print the string in a manner such that a character comes first in string displays… Read More »

Count characters at same position as in English alphabetsDecember 7, 2016

Given a string of lower and uppercase characters, the task is to find that how many characters are at same position as in English alphabets.… Read More »

Find if an array of strings can be chained to form a circle | Set 2

Given an array of strings, find if the given strings can be chained to form a circle.