We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8973db1 commit c04ffdcCopy full SHA for c04ffdc
src/main/java/com/fishercoder/solutions/firstthousand/_264.java
@@ -75,13 +75,12 @@ public static class Solution3 {
75
public int nthUglyNumber(int n) {
76
TreeSet<Long> treeSet = new TreeSet<>();
77
treeSet.add(1L);
78
- int[] arr = new int[]{2, 3, 5};
79
long currentUgly = 0;
80
for (int i = 0; i < n; i++) {
81
currentUgly = treeSet.pollFirst();
82
- treeSet.add(currentUgly * arr[0]);
83
- treeSet.add(currentUgly * arr[1]);
84
- treeSet.add(currentUgly * arr[2]);
+ treeSet.add(currentUgly * 2);
+ treeSet.add(currentUgly * 3);
+ treeSet.add(currentUgly * 5);
85
}
86
return (int) currentUgly;
87
0 commit comments