Skip to content

Tag Archives: lexicographic-ordering

Given n strings, concatenate them in an order that produces the lexicographically smallest possible string.Examples:   Input : a[] = ["c", "cb", "cba"] Output : cbacbc… Read More
Given an array arr[], find the lexicographically largest array that can be obtained by performing at-most k consecutive swaps.  Examples :  Input : arr[] =… Read More
Given a number K and a string S, We have to Find the lexicographically smallest string str of length K such that it’s set of… Read More
Given a string, find concatenation of all substrings in lexicographic order.Examples:   Input : s = “abc” Output : aababcbbcc The substrings of s in lexicographic order are… Read More
Given a string S. Print the lexicographically smallest string possible. You can make minimal changes to the characters in the string and you can permute… Read More
Given two strings S and T, find a string of the same length which is lexicographically greater than S and smaller than T. Print “-1”… Read More
Given a strings, we need to sort the words in lexicographical order (dictionary order). Examples : Input : "hello python program how are you" Output… Read More
Given a string of lowercase alphabets. Some of characters of given string got corrupted and are now represented by *. We can replace * with… Read More
Given an array of n positive integers such that each element of an integer is from 1 to n. Find the lexicographically permutation that can… Read More
Given a string, find lexicographically next string.Examples:   Input : geeks Output : geekt The last character 's' is changed to 't'. Input : raavz Output… Read More
Given a lowercase string A of length N and an integer K, find the lexicographically smallest string B of the same length as A such… Read More
Given a string S and an integer K. The task is to find lexicographically largest subsequence of S, say T, such that every character in… Read More
In this article, we will discuss how we can compare two strings lexicographically in Java. One solution is to use Java compareTo() method. The method… Read More
Given a string str. The problem is to rearrange characters of the given string such that the vowels and consonants occupy alternate position and the… Read More
Given a positive integer n, find the lexicographically smallest permutation p of {1, 2, .. n} such that pi != i. i.e., i should not… Read More

Start Your Coding Journey Now!