Skip to content

Commit 71b03cb

Browse files
committed
Optimize isValidCheck.
1 parent 989d67b commit 71b03cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/2020/day9/part1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const isValid = (nextNumber: number, arrayToCompare: number[]) => {
22
const arrayLength = arrayToCompare.length;
33
for (let i = 0; i < arrayLength; i++) {
4-
for (let j = 1; j < arrayLength; j++) {
4+
for (let j = i + 1; j < arrayLength; j++) {
55
const a = arrayToCompare[i];
66
const b = arrayToCompare[j];
77
if (a + b === nextNumber && a !== b) return true;

0 commit comments

Comments
 (0)