simple JAVA solution


  • 0
    H

    public int countNumbersWithUniqueDigits(int n) {
    if(n==0)
    return 1;
    if(n==1)
    return 10;

        int count=10;
        int base = 9;
        for(int i=0; i < n-1;i++){
            base = base*(9 - i);
            count = base + count;
        }    
        return count;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.