FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

twice as fast · JoshP/ProjectEuler-Java@f4e9316 · GitHub

Repository navigation

Commit f4e9316

Browse files
Josh
committed
twice as fast
1 parent b845b0c commit f4e9316

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Sol24.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ public void runSolution() {
2424

2525
public void next(int[] a) {
2626
int k = -1;
27-
for (int i = 0; i < a.length; i++) { // TODO reverse?
28-
if (i < a.length - 1 && a[i] < a[i + 1])
27+
for (int i = a.length - 2; i >= 0; i--) {
28+
if (a[i] < a[i + 1]) {
2929
k = i;
30+
break;
31+
}
3032
}
3133
if (k == -1) {
3234
System.out.println("found last");

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL