Category Archives: Strings

Questions related to strings

Boggle | Set 2 (Using Trie)

Given a dictionary, a method to do lookup in dictionary and a M x N board where every cell has one character. Find all possible words that can be formed by a sequence of adjacent characters. Note that we can move to any of 8 adjacent characters, but a word should not have multiple instances… Read More »

Check whether Strings are k distance apart or not

Given two strings, the task is to find if they are only less than or equal to k edit distance apart. It means that strings are only k edit distance apart when there are only k mismatches. Print Yes if there are less than or equal to k mismatches, Else No. Also print yes if… Read More »

Queries on subsequence of string

Given a string S and Q queries, each query contains a string T. The task is print “Yes” if T is subsequence of S, else print “No”. Examples: Input : S = “geeksforgeeks” Query 1: “gg” Query 2: “gro” Query 3: “gfg” Query 4: “orf” Output : Yes No Yes No For each query, using… Read More »

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 »