# Category Archives: Strings

Given a number, find the next smallest palindrome larger than this number. For example, if the input number is “2 3 5 4 5”, the… Read More
Given a string, a partitioning of the string is a palindrome partitioning if every substring of the partition is a palindrome. For example, “aba|b|bbabb|a|b|aba” is… Read More
Pattern searching is an important problem in computer science. When we do search for a string in a notepad/word file, browser, or database, pattern searching… Read More
Given a sequence, find the length of the longest palindromic subsequence in it.  Become a success story instead of just reading about them. Prepare… Read More
Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is another string… Read More
Given three strings A, B and C. Write a function that checks whether C is an interleaving of A and B. It may be assumed… Read More
Given two strings str1 and str2, write a function that prints all interleavings of the given two strings. You may assume that all characters in… Read More
Given a string of length n, print all permutations of the given string. Repetition of characters is allowed. Print these permutations in lexicographically sorted order … Read More
Given a string str, find the length of the longest substring without repeating characters.  For “ABDEFGABEF”, the longest substring are “BDEFGA” and “DEFGAB”, with… Read More
We have discussed Overlapping Subproblems and Optimal Substructure properties in Set 1 and Set 2 respectively. We also discussed one example problem in Set… Read More
Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More
Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More
Given two strings, string1 and string2, the task is to find the smallest substring in string1 containing all characters of string2 efficiently.  Examples: Become a success… Read More
Given an input string, write a function that returns the Run Length Encoded string for the input string.For example, if the input string is “wwwwaaadexxxxxx”,… Read More
Example: Let the input string be “i like this program very much”. The function should change the string to “much very program this like i”… Read More