Simple and Easy to understand CPP solution.
Intuition\nThe code checks if a given number n is fascinating or not by following a specific approach. It concatenates n, 2n, and 3n, sorts the resulting string
# Intuition\nThe code checks if a given number n is fascinating or not by following a specific approach. It concatenates n, 2n, and 3n, sorts the resulting string, and then checks for any repeated digits or zeros. If there are any repeated digits or zeros, the number is considered not fascinating.\n\n# Approach\n- Multiply the given number n by 2 and 3 to obtain n2 and n3, respectively.\n- Convert n, n2, and n3 to strings using the to_string function.\n- Concatenate the three strings (s, s2, and s3) to form a single string called ans.\n- **Sort the characters in the ans string in ascending order using the sort function**.\n- Iterate through each character in ans from the beginning to the second-to-last character.\n    - If the current character is \'0\' or the same as the next character, return false as the fascinating property is violated.\n- If no violations are found during the iteration, return true, indicating that the number n is fascinating.\n\nIn summary, the code **concatenates the string** representations of n, 2n, and 3n, **sorts the resulting string**, and checks for any **repeated digits or zeros**. This approach efficiently determines whether a number is fascinating or not based on the defined properties\n\n# Complexity\n- Time complexity:\n**O(nlogn)**\n\n\n\n# Code\n```\nclass Solution {\npublic:\n    bool isFascinating(int n) {\n\n        int n2 = 2*n;\n        int n3 = 3*n;\n\n        string s = to_string(n);\n        string s2 = to_string(n2);\n        string s3 = to_string(n3);\n\n        string ans = s+s2+s3;\n        sort(ans.begin(), ans.end());\n        for(int i=0; i<ans.length()-1;i++){\n            if(ans[i] == \'0\' || ans[i] == ans[i+1]){\n                return false;\n            }\n        }\n        return true;          \n    }\n};\n```
['String', 'Sorting', 'C++']