```
public class Solution{
public int countNumbersWithUniqueDigits(int n){
if(n==0){
return 1;
}
int[] count=new int[1];
helper(0,0,new boolean[10],count,n);
return count[0];
}
public void helper(int num,int index,boolean[] used,int[] count,int n){
if(index>0){
count[0]++;
}
if(index==n){
return;
}
for(int i=0;i<=9;i++){
if(used[0]&&index==1){
continue;
}
if(!used[i]){
used[i]=true;
helper(num*10+i,index+1,used,count,n);
used[i]=false;
}
}
}
```

}