Digit DP || Short & Simple Code || Explained
Intuition\n\nNo. having at least   =  Total   -   No. having only\n 1 repeating digit       Numbers       unique digits\n\n=>    Ans             =    n+1   -   
# Intuition\n```\nNo. having at least   =  Total   -   No. having only\n 1 repeating digit       Numbers       unique digits\n\n=>    Ans             =    n+1   -   solve(.........)\n```\n# Complexity\n- Time complexity: $$O(11*2*2*1024)$$ \n\n- Space complexity: $$O(11*2*2*1024)$$ \n\n# Code\n```\n\'int dp[11][2][2][1<<10];\nclass Solution {\n    int solve(int i, int bound, int zero, int mask, int len, string s)\n    {\n        if(i == len) //base case\n         return 1;\n\n        if(dp[i][bound][zero][mask] != -1) //memoization step\n         return dp[i][bound][zero][mask];\n\n        int curr = 0, maxDigit = bound ? (s[i]-\'0\') : 9;\n            for(int j=0; j<=maxDigit; j++)\n            {\n                if(mask == 0 && j == 0) //in case of leading 0\n                  curr += solve(i+1,bound & (j==(s[i]-\'0\')),zero,mask,len,s);\n                else if((mask & (1<<j)) == 0 || zero) //check that digit j should not have repeated \n                  curr += solve(i+1,bound & (j==(s[i]-\'0\')),zero&(j==0),mask|(1<<j),len,s);\n            }\n     return dp[i][bound][zero][mask] = curr;\n    }\npublic:\n    int numDupDigitsAtMostN(int n) {\n        memset(dp,-1,sizeof(dp)); //initializing dp with -1\n        string s = to_string(n);\n        int len = s.length();\n        return n+1 - solve(0,1,1,0,len,s);\n    } \n        \n};\n```
['Dynamic Programming', 'C++']