1
class Solution {
2
public:
3
int nthUglyNumber(int n) {
4
set<long> st;
5
st.insert(1);
6
long num = 1;
7
for (int i = 0; i < n; i++) {
8
num = *st.begin();
9
st.erase(num);
10
st.insert(num * 2);
11
st.insert(num * 3);
12
st.insert(num * 5);
13
}
14
return num;
15
}
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0