<p>Given an integer <code>n</code>, return the count of all numbers with unique digits, <code>x</code>, where <code>0 &lt;= x &lt; 10<sup>n</sup></code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 91
<strong>Explanation:</strong> The answer should be the total numbers in the range of 0 &le; x &lt; 100, excluding 11,22,33,44,55,66,77,88,99
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 0
<strong>Output:</strong> 1
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>0 &lt;= n &lt;= 8</code></li>
</ul>

class Solution {
public:
    int cnw(int n,vector<vector<int> >&dp,int store,int i){
        if(i==n){
            return 1;
        }
        if(dp[i][store]!=-1){
            return dp[i][store];
        }
        if(i==0){
            int ans=0;
            for(int j=1;j<=9;j++){
                if((store&(1<<j))==0){
                    ans+=cnw(n,dp,(store|(1<<j)),i+1);


                }
            }
            return dp[i][store]=ans;

        }
        else{
            int ans=0;
            for(int j=0;j<=9;j++){
                if((store&(1<<j))==0){
                    
                    ans+=cnw(n,dp,(store|(1<<j)),i+1);


                }

            }
          
            return dp[i][store]=ans;


        }
    }
    int countNumbersWithUniqueDigits(int n) {
        vector<vector<int> >dp(n,vector<int>(1024,-1));
        int ans= cnw(n,dp,0,0);
        if(n==0){
            return ans;
        }
        if(n==1){
            return ans+1;
        }
        int temp=0;
        int temp2=9;
        int x=8;
        n--;
        while(n>1){
            temp+=temp2;
            temp2=temp2*x;
            x--;
            n--;
        }
        ans+=(temp+1)*9+1;
        return ans;

        

    }
};
7900