Unique digit count
Practice
3.7 (3 votes)
Algorithms
Bitmask
Dynamic programming
Digitdp
4d dynamic programming
Problem
57% Success 206 Attempts 30 Points 2s Time Limit 254MB Memory 1024 KB Max Code
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
\(1 \le T \le 10\\
1 \le L,\ R \le 10^{18}\\
1 \le k \le 7\)
Explanation
The 2-special numbers in the range 1 - 12 are 10, 12. Hence the count of 2-special numbers are 2.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
MediumAlgorithmsMathematicsOpenApprovedGame Theory
Points:30
Tags:
Linear AlgebraMediumMathematics
Points:30
Tags:
Medium
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output