## Lexicographically smallest permutation of {1, .. n} such that no. and position do not match

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 »

- Check whether two strings contain same characters in same order
- Implementing next_permutation() in Java with Examples
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- Print a number as string of 'A' and 'B' in lexicographic order
- Find the lexicographically smallest sequence which can be formed by re-arranging elements of second array
- Check if string can be made lexicographically smaller by reversing any substring
- Swap all occurrences of two characters to get lexicographically smallest string
- Make lexicographically smallest palindrome by substituting missing characters
- Reorder the position of the words in alphabetical order
- Order of indices which is lexicographically smallest and sum of elements is <= X
- Print the lexicographically smallest array by swapping elements whose sum is odd
- Lexicographically smallest string formed by appending a character from first K characters of a string | Set 2
- Find the lexicographical next balanced bracket sequence
- Queries to answer the X-th smallest sub-string lexicographically
- Queries to print the character that occurs the maximum number of times in a given range
- Lexicographical smallest alternate Array

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 »

C++ STL offer many utilities to solve basic common life problems. Comparing values are always necessary, but sometimes we need to compare the strings also.… Read More »

Given a string s, make a list of all possible combinations of letters of a given string S. If there are two strings with the… Read More »

Given a string of length m containing lowercase alphabets only. You have to find the n-th permutation of string lexicographically. Examples: Input : str[] =… Read More »

Write code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic minimum is ABBCABDAD Input Constraint: 1 < n… Read More »

Rearrange the characters of the given string to form a lexicographically first palindromic string. If no such string exists display message “no palindromic string”. Examples:… Read More »

Given an array arr[], find the lexicographically smallest array that can be obtained after performing at maximum of k consecutive swaps. Examples : Input: arr[]… Read More »

You are given two strings.Now you have to print all longest common sub-sequences in lexicographical order? Examples: Input : str1 = “abcabcaa”, str2 = “acbacba”… Read More »

Given a word, find lexicographically smaller permutation of it. For example, lexicographically smaller permutation of “4321” is “4312” and next smaller permutation of “4312” is… Read More »

Given a word, find the lexicographically greater permutation of it. For example, lexicographically next permutation of “gfg” is “ggf” and next permutation of “acb” is… Read More »

Write code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic minimum is ABBCABDAD. Source: Google Written Test More… Read More »

Given a string, print all permutations of it in sorted order. For example, if the input string is “ABC”, then output should be “ABC, ACB,… Read More »