leetcode-华为专题-剑指 Offer 49. 丑数
class Solution { public: int nthUglyNumber(int n) { vector<int> res(n,1); int a = 0; int b = 0; int c = 0; for(int i = 1; i < n; i++){ // 定义三个指针分别维护 2 3 5 int temp = min(min(res[a]*2,res[b]*3),res[c]*5); res[i] = temp; if(temp == res[a]*2) a++; if(temp == res[b]*3) b++; if(temp == res[c]*5) c++; } return res[n-1]; } };