C++ | DIGIT-DP | BIT-MASKING
PLEASE UPVOTE IF U FIND MY SOLUTION HELPFUL :)\n\n\nclass Solution\n{\n    int dp[1<<10][10][2][2];\n    int helper(string &s,int i,int mask,int lz,int bound)\n
**PLEASE UPVOTE IF U FIND MY SOLUTION HELPFUL :)**\n\n```\nclass Solution\n{\n    int dp[1<<10][10][2][2];\n    int helper(string &s,int i,int mask,int lz,int bound)\n    {\n        if(i==s.length())return 1;\n        \n        if(dp[mask][i][lz][bound]!=-1)\n            return dp[mask][i][lz][bound];\n        \n        int maxx=bound?s[i]-\'0\':9;\n        \n        int tot=0;\n        \n        for(int j=0;j<=maxx;j++)\n        {\n            if((mask&(1<<j))&&lz==0)continue;\n            mask|=(1<<j);\n            tot+=helper(s,i+1,mask,lz&(j==0),bound&(j==maxx));\n            mask^=(1<<j);\n        }\n        \n        return dp[mask][i][lz][bound]=tot;\n    }\n    public:\n        int numDupDigitsAtMostN(int n)\n        {\n            string s=to_string(n);\n            memset(dp,-1,sizeof(dp));\n            int mask=0;\n            int res=(n+1)-helper(s,0,mask,1,1);\n            return res;\n        }\n};\n```
['Bitmask']