Am I the only one who misunderstand the question?
I spent over 1 hr debugging couldn\'t figure out why my answer is wrong for some large numbers. \n\nThe question states that have at least one repeated digit. I
I spent over 1 hr debugging couldn\'t figure out why my answer is wrong for some large numbers. \n\nThe question states that have at least one repeated digit. I took that to mean "101" is NOT OK because both "1" are not glued together, and "11" is OK because they are together.\n\nI eventually gave up and checked the solution and realized "101" is actually OK because "1" appears twice. Am I the only person who didn\'t understand the question? \n\nIt is really frustrating.\n\n```Java\nclass Solution {\n    public int numDupDigitsAtMostN(int n) {\n        // 983582\n        // 108318\n        int ttl = n++;\n        int ans = 0;\n        List<Integer> list = new ArrayList<>();\n        while(n>0){\n            list.add(n%10);\n            n/=10;\n        }\n        for (int i = 1; i < list.size(); i++){\n            ans+=9*find(i-1, 9);\n        }\n        boolean[] seen = new boolean[10];\n        for (int i = list.size(), d = 9; i > 0; --i, d--){\n            int count = i == list.size()? list.get(i-1)-1: list.get(i-1);\n            for (int j = 0; j < list.get(i-1); j++){\n                if (seen[j]){\n                    count--;\n                }\n            }\n            ans += count*find(i-1, d);\n            if (seen[list.get(i-1)]){\n                break;\n            }\n            seen[list.get(i-1)]=true;\n        }\n        return ttl-ans;\n    }\n\n    private int find(int n, int d){\n        // dCn*n!\n        // d!/(d-n)/(d-n).../1\n        int ans = 1;\n        for (int i = 1; i <= d; i++){\n            ans *= i;\n        }\n        for (int i = n+1; i <= d; i++){\n            ans /= (i-n);\n        }\n        return ans;\n    }\n}\n```
['Java']