Category Archives: Strings

Questions related to strings

Queries for characters in a repeated string

Given a string X. Form a string S by repeating string X multiple times i.e appending string X multiple times with itself. There are Q queries of form i and j. The task is to print “Yes” if the element at index i is same as the element at index j in S else print… Read More »

Program to toggle all characters in a string

in a given string in which we toggle all characters. Examples: Input : gfg Output : GFG Input : aBc12# Output : AbC12# Input : tu@kmiNi Output : TU@KMInI Traverse the given string, if uppercase characters comes, convert into lowercase and lowercase latter convert into uppercase. Output: gEkF@RgEEK$ This article is contributed by MATHE_KA_BANDA. If… Read More »

Check if two strings are k-anagrams or not

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. Two strings are called k-anagrams if following two conditions are true. Both have same number of characters. Two strings can become anagram by changing at most k characters in a… Read More »

Count of character pairs at same distance as in English alphabets

Given a string, the task is to count the number of pairs whose elements are at same distances as in the English alphabets. Note : Absolute distance between characters is considered. Examples: Input: str = “geeksforgeeks” Output: 4 Explanation: In this (g,s),(e,g),(e,k),(e,g) are the pairs that are at same distances as in English alphabets. Input:… Read More »

Print all palindromic partitions of a string

Given a string s, partition s such that every string of the partition is a palindrome. Return all possible palindrome partitioning of s. Example : Input : s = “bcc” Output : [[“b”, “c”, “c”], [“b”, “cc”]] Input : s = “geeks” Output : [[“g”, “e”, “e”, “k”, “s”], [“g”, “ee”, “k”, “s”]] We have… Read More »