一图搞懂!!!代码都差不多
图片说明

public int GetUglyNumber_Solution(int index) {
        if (index < 7) {
            return index;
        }
        int p2 = 0, p3 = 0, p5 = 0;  //三个指针
        int[] a = new int[index];
        a[0] = 1;
        for (int i = 1; i < index; i++) {
            a[i] = Math.min(a[p2] * 2, Math.min(a[p3] * 3, a[p5] * 5));
            if (a[i] == a[p2] * 2) {
                p2++;
            }
            if (a[i] == a[p3] * 3) {
                p3++;
            }
            if (a[i] == a[p5] * 5) {
                p5++;
            }
        }
        return a[index - 1];
    }