Unique digit count

3.7

3 votes
Algorithms, Bitmask, Dynamic Programming, DigitDP, 4D dynamic programming
Problem

 You are given a range L to R. You are required to find the number of k-special numbers in this range (inclusive). A  k-special number is a number that has exactly k unique digits.

For example:

  • 26 is a 2-special number. Digits 2 and 6 are unique.
  • 6643 is a 3-special number. Digits 6, 4, and 3 are unique.

Constraints
1T101L, R10181k7

Time Limit: 2
Memory Limit: 254
Source Limit:
Explanation

The 2-special numbers in the range 1 - 12 are 10, 12. Hence the count of 2-special numbers are 2.

Editor Image

?