We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d9cb362 commit 148c85cCopy full SHA for 148c85c
src/bin/count-numbers-with-unique-digits.rs
@@ -0,0 +1,27 @@
1
+fn main() {
2
+ println!("{}", Solution::count_numbers_with_unique_digits(2));
3
+ println!("{}", Solution::count_numbers_with_unique_digits(8));
4
+ println!("{}", Solution::count_numbers_with_unique_digits(7));
5
+}
6
+
7
+struct Solution;
8
9
+impl Solution {
10
+ pub fn count_numbers_with_unique_digits(n: i32) -> i32 {
11
+ if n == 0 {
12
+ return 1;
13
+ }
14
15
+ if n == 1 {
16
+ return 10;
17
18
19
+ let mut sum =9;
20
21
+ for i in 0..n - 1 {
22
+ sum *= 9 - i;
23
24
25
+ sum + Self::count_numbers_with_unique_digits(n - 1)
26
27
0 commit comments