Lexicographically smallest K-length subsequence from a given string
Given a string S of length N, the task is to find the lexicographically smallest K-length subsequence from the string S (where K < N)....
read more
Reverse substrings between each pair of parenthesis
Given a string str that consists of lowercase English letters and brackets. The task is to reverse the substrings in each pair of matching parentheses, starting from the innermost one. The result should not contain any brackets....
read more
CSES solution-Repeating Substring
A repeating substring is a substring that occurs in two (or more) locations in the string. Your task is to find the longest repeating substring in a given string....
read more
Minimum Moves for adjacent stars
Given a string s consisting of ‘.’ and ‘*’, In one move you can shift ‘*’, one index left or one index right if there is a ‘.’ present there, the task is to make an arrangement such that all the * are adjacent to each other i.e. there is no ‘.’ between any two ‘*’ Print the minimum number of moves required to do so....
read more
Python | C++ | Remove leading zeros from an IP address
Given an IP address, remove leading zeros from the IP address....
read more
Given a string and an integer k, find the kth sub-string when all the sub-strings are sorted according to the given condition
Given a string str, its sub-strings are formed in such a way that all the sub-strings starting with the first character of the string will occur first in the sorted order of their lengths followed by all the sub-strings starting with the second character of the string in the sorted order of their lengths and so on. For example for the string abc, its sub-strings in the required order are a, ab, abc, b, bc and c. Now given an integer k, the task is to find the kth sub-string in the required order.Examples:...
read more
Check If every group of a’s is followed by a group of b’s of same length
Given string str, the task is to check whether every group of consecutive a’s is followed by a group of consecutive b’s of the same length. If the condition is true for every group then print 1 else print 0....
read more
Python3 Program for Left Rotation and Right Rotation of a String
Given a string of size n, write functions to perform the following operations on a string-...
read more
Minimum substring removals required to make all remaining characters of a string same
Given a string str of length N, the task is to find the minimum number of substrings required to be removed to make all the remaining characters of the string same....
read more
Remove characters from a String that appears exactly K times
Given a string of lowercase letters str of length N, the task is to reduce it by removing the characters which appear exactly K times in the string....
read more
Maximum length of consecutive 1’s in a binary string in Python using Map function
We are given a binary string containing 1’s and 0’s. Find the maximum length of consecutive 1’s in it....
read more
C# Program to check if strings are rotations of each other or not
Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1? (eg given s1 = ABCD and s2 = CDAB, return true, given s1 = ABCD, and s2 = ACBD , return false) Algorithm: areRotations(str1, str2)...
read more