Given a range find total such numbers in the given range such that they have no repeated digits.
12 has no repeated digit.
22 has repeated digit.
102, 194 and 213 have no repeated digit.
212, 171 and 4004 have repeated digits.
Input : 10 12 Output : 2 Explanation : In the given range 10 and 12 have no repeated digit where as 11 has repeated digit. Input : 1 100 Output : 90
We will traverse through each element in the given range and count the number of digits which do not have repeated digits.
This method will answer each query in O( N ) time.
We will calculate a prefix array of the numbers which have no repeated digit.
= Total number with no repeated digit less than or equal to 1.
Therefore each query can be solved in O(1) time.
Below is the implementation of above idea.
- Squares of numbers with repeated single digits | Set 1 (3, 6 and 9)
- Total number of non-decreasing numbers with n digits
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Count of numbers from range [L, R] whose sum of digits is Y
- Count of Numbers in Range where the number does not contain more than K non zero digits
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3
- Count numbers in range L-R that are divisible by all of its non-zero digits
- Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime
- Remove repeated digits in a given number
- Recursive sum of digits of a number formed by repeated appends
- Count ways to spell a number with repeated digits
- Find the total Number of Digits in (N!)N
- Count total number of digits from 1 to n
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.