package leetcode;

/**
 * https://leetcode.com/problems/count-numbers-with-unique-digits/
 */
public class Problem357 {
    public int countNumbersWithUniqueDigits(int n) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem357 prob = new Problem357();
        System.out.println(prob.countNumbersWithUniqueDigits(2)); // 91
        System.out.println(prob.countNumbersWithUniqueDigits(1)); // 10
        System.out.println(prob.countNumbersWithUniqueDigits(0)); // 1
    }
}

@@ -178,32 +178,506 @@
     
-// TODO
+return countNumbersWithUniqueDigits(n, 0, new boolean%5B10%5D);
 %0A    
+%7D%0A%0A
     
-return 0
+private int countNumbersWithUniqueDigits(int n, int m, boolean%5B%5D visited) %7B%0A        if (n == m) %7B%0A            return 1;%0A        %7D%0A        int count = 1;%0A        for (int i = (m == 0) ? 1 : 0; i %3C= 9; i++) %7B%0A            if (!visited%5Bi%5D) %7B%0A                visited%5Bi%5D = true;%0A                count += countNumbersWithUniqueDigits(n, m + 1, visited);%0A                visited%5Bi%5D = false;%0A            %7D%0A        %7D%0A        return count
 ;%0A  
@@ -770,16 +770,163 @@
 m357();%0A
+        System.out.println(prob.countNumbersWithUniqueDigits(4)); // 5275%0A        System.out.println(prob.countNumbersWithUniqueDigits(3)); // 739%0A
         
@@ -989,16 +989,18 @@
 ; // 91%0A
+//
         
@@ -1063,16 +1063,18 @@
 ; // 10%0A
+//
         

Solve problem 357