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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Generate all binary permutations such that there are more or equal 1's than 0's before every point in all permutations
- Smallest subarray of size greater than K with sum greater than a given value
- Print all lexicographical greater permutations of a given string
- Largest Divisor for each element in an array other than 1 and the number itself
- Count of elements having Euler's Totient value one less than itself
- Largest number with maximum trailing nines which is less than N and greater than N-D
- Largest number less than N with digit sum greater than the digit sum of N
- Sum of GCD of all numbers upto N with N itself
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Highest and Smallest power of K less than and greater than equal to N respectively
- Maximize a number considering permutations with values smaller than limit
- Count of numbers whose sum of increasing powers of digits is equal to the number itself
- Count array elements having modular inverse under given prime number P equal to itself
- Write a program to print all permutations of a given string
- Print all permutations with repetition of characters
- Print all permutations in sorted (lexicographic) order
- Print all distinct permutations of a given string with duplicates
- Print all palindrome permutations of a string
- Print all the palindromic permutations of given string in alphabetic order
- Print all permutations of a string in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.