Given string str of lower case English alphabets. One can choose any two characters in the string and replace all the occurrences of the first character with the second character and replace all the occurrences of the second character with the first character. Find the lexicographically smallest string that can be obtained by doing this operation at most once. Examples:...
Given a string S of length N and an integer K, the task is to find the frequency of the lexicographically Kth smallest character present in the given string....
Given a positive integer N, the task is to construct the lexicographically largest array of size (2 * N – 1) comprising of first N natural numbers such that each element occurs twice except 1 and the repetition of X is exactly X distance apart in the constructed array....
Given a balanced bracket sequence as a string str containing character ‘(‘ or ‘)’, the task is to find the next lexicographical order balanced sequence if possible else print -1.Examples:...
Given an integer W and an array a[] of size 26 where ai denotes the cost of using the ith alphabet, the task is to find lexicographically the largest string that can be generated for a cost, W....
Given an array arr[], find the lexicographically largest array that can be obtained by performing at-most k consecutive swaps....
Given two strings str1 and str2 of same length N, the task is to check if there exists any permutation possible in any of the given strings, such that every character of one string is greater or equal to every character of the other string, at corresponding indices. Return true if permutation exists otherwise false....
Given string S and a positive integer K, the task is to find lexicographically the largest possible string using at most K swaps with the condition that the indices that are swapped must be either both odd or both even....
Given a string S, the task is to find the string which is lexicographically smallest and not a subsequence of the given string S....
Given a string S consisting of lowercase alphabets, the task is to find the lexicographically smallest string that can be obtained by removing duplicates from the given string S....
Given a string of length m containing lowercase alphabets only. You have to find the n-th permutation of string lexicographically....
Given two strings X and Y of lowercase letters, of length N and M respectively, the task is to build another string Z by performing two types of operations:...