easy C++ solution
Intuition\nThe problem requires checking whether a number is fascinating or not. A fascinating number is one that, when multiplied by 2 and 3, results in a conc
# Intuition\nThe problem requires checking whether a number is fascinating or not. A fascinating number is one that, when multiplied by 2 and 3, results in a concatenated string of the original number, double the original number, and triple the original number containing all digits from 1 to 9 exactly once.\n\n# Approach\n\n1> convert the original number n, n * 2, and n * 3 to strings (s, s1, s2).\n\n2> Concatenate the three strings into a single string s3.\n\n3> Sort the characters in s3 in ascending order.\n\n4> If the length of s3 is less than 9, return false (as it cannot contain all digits from 1 to 9).\n\n5> Iterate through each character in the sorted string s3.\nCheck if the character at position i is equal to the expected character based on the loop variable i.\n\nIf any character is not equal, return false; otherwise, return true.\n\n# Complexity\n- Time complexity:\nO(n * log(n))\n\n- Space complexity:\no(n)\n\n# Code\n```\n#include <iostream>\n#include <string>\n#include <algorithm>\n\nclass Solution {\npublic:\n    bool isFascinating(int n) {\n        string s = to_string(n);\n        string s1 = to_string(n * 2);\n        string s2 = to_string(n * 3);\n\n        string s3 = s + s1 + s2;\n\n        sort(s3.begin(), s3.end());\n\n        if (s3.length() < 9) {\n            return false;\n        }\n\n        for (int i = 0; i < s3.length(); i++) {\n            if (s3[i] != \'1\' + i) {\n                return false;\n            }\n        }\n        return true;\n    }\n};\n\n```
['C++']