Skip to content

Commit

Permalink
Merge pull request #27 from Abhinav1101/main
Browse files Browse the repository at this point in the history
Added count numbers with unique digits
  • Loading branch information
sumitsojha88 authored Oct 26, 2021
2 parents e6b6519 + a173962 commit 640ee0c
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution {
public:
int cal(int n){
int val =9,dif=9;
while(n>1){
dif*=val;
val--;
n--;
}
return dif;
}
int countNumbersWithUniqueDigits(int n) {
if(n==0)
return 1;
int ans = 10;
for(int i=2;i<=n;i++)
ans+=cal(i);
return ans;
}
};

0 comments on commit 640ee0c

Please sign in to comment.