Given an integer N, the task is to find the next number with distinct digits in it.
Input: N = 20
The next integer with all distinct digits after 20 is 21.
Input: N = 2019
- Count the total number of digits in the number N using the approach discussed in this article.
- Count the total number of distinct digits in N.
- If the count of total number of digits and number of distinct digits in N is equal then return the number otherwise increment the number by one and repeat the previous steps.
Below is the implementation of the above approach:
- Print a number strictly less than a given number such that all its digits are distinct.
- Numbers having Unique (or Distinct) digits
- Check if the sum of distinct digits of two integers are equal
- Count of N-digit numbers with all distinct digits
- Count distinct pairs from two arrays having same sum of digits
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Find smallest number with given number of digits and sum of digits under given constraints
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Number formed by deleting digits such that sum of the digits becomes even and the number odd
- Find smallest number with given number of digits and sum of digits
- Find the Largest number with given number of digits and sum of digits
- Find the average of k digits from the beginning and l digits from the end of the given number
- Minimum number of digits to be removed so that no two consecutive digits are same
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.