C++ math approach, string concatenation w/ a set, and the optimal solution
Math Approach (no strings)Note: Since n is an integer from [100, 999] we don't have to check for n == 0 thus a log10 function is good since n > 0.
For this to w
# Math Approach (no strings)
<!-- Describe your approach to solving the problem. -->
**Note:** Since n is an integer from [100, 999] we don't have to check for n == 0 thus a log10 function is good since n > 0. 
1) For this to work, we need to either check if the 3n is a 4 digit number and if it is, we return false. 
2) To get our total number, we can just do 1_000_000 * n + 1_000 * 2n + 3n = 1_002_003n. This will be sure to place the digits in the correct spots for each 3 digit number. 
3) initialize an array (digit counter) and keep count of all the digits in the total. 
4) Check if 1-9 appear only once
5) check if there is any 0 in the arr, if there is return false if not return true

# String concatination approach:
1) Concat the strings n + n*2 + n*3.
2) Check if the length of the string is 9. Only way for 9 digits to appear once and no zero. 
3) Initialize a set with all the digits in it.
4) if the set is {'1', '2', '3', '4', '5', '6', '7', '8', '9'}, then return true. (hence checking that the size is 9) But if there is a 0 at all, return false. 

# Last approach:
1) if n is any of these numbers in the set {192, 219, 273, 327} then it is true, else false. 

**NOTE**: I found this out from just making a loop from 100-999 inclusive since these are the constraints and find that these are the only numbers that satisfy this problem. 

# Time and space complexity:
- Time complexity: O(1)
    Since at most we iterate 9 times. O(9) -> O(1)
- Space Complexity: O(1)
    

# Code
```cpp []
// mathematical solution (no strings)
class Solution {
public:
    bool isFascinating(int n) {
        if(floor(log10(n * 3)) + 1 >= 4){
            return false;
        }
        int total = 1002003 * n;

        int arr[10] = {0};
        while(total > 0){
            arr[total % 10]++;
            total /= 10;
        }


        for(int i = 1; i < 10; i++){
            if(arr[i] > 1 || arr[i] == 0){
                return false;
            }
        }

        return arr[0] == 0;
    }
};

// string concatination solution
class Solution {
public:
    bool isFascinating(int n) {
        std::string concat_num = to_string(n) + to_string(n * 2) + to_string(n * 3);

        if(concat_num.length() != 9){
            return false;
        }

        set<char> set1(concat_num.begin(), concat_num.end()); 
        return set1.find('0') == set1.end() && set1.size() == 9;    

    }
};

// best solution
class Solution {
public:
    bool isFascinating(int n) {
        return n == 192 || n == 219 || n == 273 || n == 327;
    }
};

```
['C++']