C++ Easy To Understand Solution | Using Sets
Approach\n Describe your approach to solving the problem. \n\n1. Converting the number to string is first step.\n2. Adding all the characters to a set as it con
# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1. Converting the number to string is first step.\n2. Adding all the characters to a set as it contains only unique characters.\n3. The size of string and set must be exactly equal to 9 i.e. it contains all the digits from 1 to 9 exactly once.\n4. Last thing to check is that 0 is not present in the set.\n\n# Code\n```\nclass Solution {\npublic:\n    bool isFascinating(int n) {\n        string res = to_string(n);\n        res += to_string(2*n);\n        res += to_string(3*n);\n        \n        unordered_set<char> us(res.begin(),res.end());\n       \n        if(us.size() == 9 && res.size() == 9 && us.find(\'0\') == us.end()) \n            return true;\n        return false;\n    }\n};\n```
['C++']