Questions related to strings

Print characters having prime frequencies in order of occurrence

Given a string str containing only lowercase characters. The task is to print the characters having prime frequency in the order of their occurrence. Note… Read More »

Check if the bracket sequence can be balanced with at most one change in the position of a bracket

Given an unbalanced bracket sequence as a string str, the task is to find whether the given string can be balanced by moving at most… Read More »

Longest substring such that no three consecutive characters are same

Given string str, the task is to find the length of the longest substring of str such that no three consecutive characters in the substring… Read More »

Find the winner of the game

Two players are playing a game where a string str is given. The first player can take the characters at even indices and the second… Read More »

Print characters having even frequencies in order of occurrence

Given a string str containing only lowercase characters. The task is to print the characters having an even frequency in the order of their occurrence.… Read More »

Compare two strings considering only alphanumeric characters

Given two strings that can contain lower and uppercase alphabets, numbers and special characters like dots, blank spaces, commas, etc. Compare both strings considering only… Read More »

Minimum given operations required to convert a given binary string to all 1’s

Given a binary number as a string str of length L. The task is to find the minimum number of operations needed so that the… Read More »

Reverse the given string in the range [L, R]

Given a string str, and two integers L and R, the task is to reverse the string in the range [L, R] i.e. str[L…R]. Examples:… Read More »

Lexicographically smallest string of length N and sum K

Given two integers N and K. The task is to print the lexicographically smallest string of length N consisting of lower-case English alphabates such that… Read More »

Count of characters in str1 such that after deleting anyone of them str1 becomes str2

Given two strings str1 and str2, the task is to count the characters in str1 such that after removing any one of them str1 becomes… Read More »

Expand the string according to the given conditions

Given a string str of the type “3(ab)4(cd)”, the task is to expand it to “abababcdcdcdcd” where integers are from the range [1, 9]. This… Read More »

Largest substring of str2 which is a prefix of str1

Given two string str1 and str2, the task is to find the longest prefix of str1 which is present as a substring of the string… Read More »

Check if string can be rearranged so that every Odd length Substring is Palindrome

Given a string S. The task is to check whether it is possible to rearrange the string such that every substring of odd length is… Read More »

Lexicographical ordering using Heap Sort

Given an array arr[] of strings. The task is to sort the array in lexicographical order using Heap Sort. Examples: Input: arr[] = { “banana”,… Read More »