Short and concise C++ solution | Digit DP
Intuition\nSimple digit dp problem , check if current constructed number is less than the given number and choose digits accordingly.\nTo check if a digit is re
# Intuition\nSimple digit dp problem , check if current constructed number is less than the given number and choose digits accordingly.\nTo check if a digit is repeated or not use a 0-9 digit bit mask.\n\n\n# Code\n```\nclass Solution {\npublic:\n    int dp[10][2][2][1<<10];\n    int recur(int curr,int isLess, bool isRepeated, int mask,vector<int> &digits){\n        int n = digits.size();\n        if(curr >=  n)return isRepeated;\n        if(dp[curr][isLess][isRepeated][mask] != - 1)return dp[curr][isLess][isRepeated][mask];\n        int ans = 0;\n        for(int i = 0;i <= (isLess ? 9 : digits[curr]);i++){\n            ans += recur(curr + 1,isLess | (i < digits[curr]), isRepeated | ((mask&(1<<i)) != 0), i != 0 ? (mask | (1<<i)) : (mask | (mask != 0))  ,digits);\n        }\n        return dp[curr][isLess][isRepeated][mask] = ans;\n    }\n    int numDupDigitsAtMostN(int n) {\n        vector<int> digitVector;\n        while(n > 0){\n            digitVector.push_back(n%10);\n            n = n/10;\n        }\n        reverse(digitVector.begin(),digitVector.end());\n        memset(dp,-1,sizeof(dp));\n        return recur(0,0,0,0,digitVector);\n    }\n};\n```
['C++']