My solution in c++
class Solution {\n    public:\n        long nthUglyNumber(int n) {\n           set<long> pq;\n    \t\tpq.insert(1);\n    \t\tint count = 0;\n    \t\tlong t = 1;
    class Solution {\n    public:\n        long nthUglyNumber(int n) {\n           set<long> pq;\n    \t\tpq.insert(1);\n    \t\tint count = 0;\n    \t\tlong t = 1;\n    \t\twhile (count < n)\n    \t\t{\n    \t\t\tset<long>::iterator it = pq.begin();\n    \t\t\tt = *it;\n    \t\t\tpq.erase(it);\n    \t\t\tpq.insert(t * 2);\n    \t\t\tpq.insert(t * 3);\n    \t\t\tpq.insert(t * 5);\n    \t\t\tcount++;\n            }\n            return t;\n        }\n    };
[]