Numbers With Repeated Digits || DP || C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int numDupDigitsAtMostN(int n) \n    {\n        string digit = to_string(n+1);\n        int m = digit.size();\n        int res = 0;\n        for (int i = 1; i < m; i++)\n            res += 9*A(9, i-1);\n        vector<int> seen(10, 0);\n        for (int i = 0; i < m; i++)\n        {\n            int cur = digit[i] - \'0\';\n            for (int k = (i>0) ? 0 : 1; k < cur; k++)\n                if (!seen[k]) res += A(10-(i+1), m-(i+1));\n            if (seen[cur]) break;\n            seen[cur] = 1;\n        }\n        return n-res;\n    }\nprivate:\n    int A(int a, int b)\n    {\n        if (b==0) return 1;\n        return (a-b+1)*A(a, b-1); // A(9,3) -> 7*8*9\n    }\n};\n```
['C++']