Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c04ffdc

Browse files
update 264
1 parent 8973db1 commit c04ffdc

File tree

1 file changed

+3
-4
lines changed
  • src/main/java/com/fishercoder/solutions/firstthousand

1 file changed

+3
-4
lines changed

‎src/main/java/com/fishercoder/solutions/firstthousand/_264.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ public static class Solution3 {
7575
public int nthUglyNumber(int n) {
7676
TreeSet<Long> treeSet = new TreeSet<>();
7777
treeSet.add(1L);
78-
int[] arr = new int[]{2, 3, 5};
7978
long currentUgly = 0;
8079
for (int i = 0; i < n; i++) {
8180
currentUgly = treeSet.pollFirst();
82-
treeSet.add(currentUgly * arr[0]);
83-
treeSet.add(currentUgly * arr[1]);
84-
treeSet.add(currentUgly * arr[2]);
81+
treeSet.add(currentUgly * 2);
82+
treeSet.add(currentUgly * 3);
83+
treeSet.add(currentUgly * 5);
8584
}
8685
return (int) currentUgly;
8786
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /