Given a number N, our task is to print those permutations of integer N which are greater than N.
Input: N = 534
Input: N = 324
Output: 342, 423, 432
Approach: To solve this problem, we can obtain all the lexicographically larger permutations of N using next_permutation() method in C++. After getting all such numbers, print them.
For other languages, find the permutations of number N and print the numbers which are greater than N.
Below is the implementation of above approach:
342 423 432
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Print all lexicographical greater permutations of a given string
- Print the two possible permutations from a given sequence
- Print k different sorted permutations of a given array
- Print all permutations with repetition of characters
- Print all permutations of a string in Java
- Print all palindrome permutations of a string
- Print all distinct permutations of a given string with duplicates
- Print all permutations in sorted (lexicographic) order
- Iterative approach to print all permutations of an Array
- Write a program to print all permutations of a given string
- Print first n distinct permutations of string using itertools in Python
- Print all the palindromic permutations of given string in alphabetic order
- Java Program to print distinct permutations of a string
- Print distinct sorted permutations with duplicates allowed in input
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Generate all binary permutations such that there are more or equal 1's than 0's before every point in all permutations
- Number of palindromic permutations | Set 1
- Find the number of good permutations
- Count of possible permutations of a number represented as a sum of 2's, 4's and 6's only
- Count the number of special permutations
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.