C++ method using permutation
\nauto __ =[]()\n{\n    std::ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n    return nullptr;\n}();\nclass Solution {\npublic:\n    int numDupDigitsAtMo
```\nauto __ =[]()\n{\n    std::ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n    return nullptr;\n}();\nclass Solution {\npublic:\n    int numDupDigitsAtMostN(int N) {\n        //\u65E2\u7136\u8BA1\u7B97\u7684\u662F\u91CD\u590D\u7684\u4E2A\u6570\u6211\u4EEC\u53EF\u4EE5\u8BA1\u7B97\u4E0D\u91CD\u590D\u7684\u4E2A\u6570\uFF0C\u8FD9\u5C31\u662F\u4E2A\u6392\u5217\u7EC4\u5408\u7684\u95EE\u9898\n        //\u5BF9\u4E8E\u8FD9\u4E2A\u95EE\u9898\u6211\u4EEC\u8981\u5148\u5199\u51FA\u6392\u5217\u7EC4\u5408\u7684\u7B97\u6CD5\u3002\n        // second we must define our method upper  boader.\n        // such that 8999-->(9,0,0,0) \n        // \n        int retv  = 0;\n        vector<int> remain;\n        for(int n = N+1;n>0;n/=10)\n        {\n            remain.insert(remain.begin(),n%10);\n        }\n        for(int i =1;i<remain.size();i++)\n        {\n            retv+=9*A(9,i-1);\n        }\n        // condition ,if this \u548C\u524D\u9762\u7684\u4E00\u6837\u5219\u8DF3\u8FC7\uFF0C\u56E0\u4E3A\u4E0D\u80FD\u6709\u91CD\u590D\u7684\uFF0C\u5982\u679C\u5B58\u5728\u4E24\u4E2A\u4E0A\u754C\u4E00\u6837beak \u6389\uFF0C\u56E0\u4E3A\u4E0D\u53EF\u80FD\u5728\u4ECE\u8FD9\u91CC\u51FA\u73B0\u4E24\u4E2A\u5B8C\u5168\u4E0D\u4E00\u6837\u7684\n        unordered_set<int> sets;\n        for(int i = 0;i<remain.size();i++)\n        {\n            for(int j = i==0?1:0;j<remain[i];j++)\n            {\n                if(!sets.count(j))\n                {\n                    retv += A(9-i,remain.size()-1-i);\n                }\n            }\n            if(sets.count(remain[i]))\n                break;\n            else\n            {\n                sets.insert(remain[i]);\n            }\n        }\n        return N-retv;\n        \n    }\n    int A(int n,int m)\n    {\n        //means C{n,m}\n        //How can we deal with this problem, Can you give me a method to do ?\n        //in this time, wo di it, such that.\n        //A(n,m) = n*n-1*n-2*..n-m+1 = (n-m+1)*A(n,m-1)\n        return m == 0?1:(n-m+1)*A(n,m-1);\n    }\n};\n```
[]