Given an array of words, print all anagrams together. For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then output may be… Read More
Category Archives: Strings
Given a string, find the longest substring which is a palindrome. Examples: Input: Given string :"forgeeksskeegfor", Output: "geeksskeeg". Input: Given string :"Geeks", Output: "ee". Recommended… Read More
Given a string, move all even positioned elements to the end of the string. While moving elements, keep the relative order of all even positioned… Read More
Given a string str, the task is to find the longest substring which is a palindrome. Examples: Input: str = “forgeeksskeegfor” Output: “geeksskeeg”Explanation: There are several… Read More
Given a string, print all permutations of it in sorted order. For example, if the input string is “ABC”, then output should be “ABC, ACB,… Read More
Given a string str, find its rank among all its permutations when sorted lexicographically. Note: The characters a string are all unique. Examples: Input: str… Read More
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. As another example, if the given sequence is “BBABCBCAB”, then the… Read More
Given two strings. The task is to check whether the given strings are anagrams of each other or not. An anagram of a string is… 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. Example: For “ABDEFGABEF”, the longest substring are “BDEFGA” and “DEFGAB”,… Read More