1012. Numbers With Repeated Digits
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int numDupDigitsAtMostN(int n) {
        vector<int> digits;
        int temp = n + 1;
        while (temp) {
            digits.push_back(temp % 10);
            temp /= 10;
        }
        int res = 0, len = digits.size(), mult = 9;
        for (int i = 0; i < len - 1; i++) {
            res += mult;
            mult *= 9 - i;
        }
        mult /= 9;
        vector<bool> used(10, false);
        for (int i = 0; i < len; i++) {
            int d = digits[len - i - 1];
            for (int j = i == 0 ? 1 : 0; j < d; j++) if (!used[j]) res += mult;
            mult /= 9 - i;
            if (used[d]) break;
            used[d] = true;
        }
        return n - res;
    }
};

```
['C++']