My easy understand java solution


  • 0
    F
    public int countNumbersWithUniqueDigits(int n) {
    	if (n == 0)
    		return 1;
    	int sum = 10;
    	int restNum = 10;
    	int base = 9;
    	for (int i = 2; i <= n && i<=10; i++) {
    		base *= --restNum;
    		sum += base;
    	}
    	return sum;     
    }

Log in to reply
 

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