Java Solution Using PriorityQueue
public int nthUglyNumber(int n) {\n        if(n==1) return n;\n        Queue<Long> q = new PriorityQueue<Long>();\n        int[] nums = {2,3,5};\n        Long r
    public int nthUglyNumber(int n) {\n        if(n==1) return n;\n        Queue<Long> q = new PriorityQueue<Long>();\n        int[] nums = {2,3,5};\n        Long result = Long.valueOf(1);\n        q.offer(result);\n        for(int i=0;i<n;i++){\n            // Each time we poll the peak value of q, is the ith number \n            result = q.poll();\n            for(int num:nums){\n                Long uglyNum = result*num;\n                if(!q.contains(uglyNum)){\n                    q.offer(uglyNum);\n                }\n            }\n        }\n        return result.intValue();\n    }
['Java']