We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 989d67b commit 71b03cbCopy full SHA for 71b03cb
src/2020/day9/part1.ts
@@ -1,7 +1,7 @@
1
const isValid = (nextNumber: number, arrayToCompare: number[]) => {
2
const arrayLength = arrayToCompare.length;
3
for (let i = 0; i < arrayLength; i++) {
4
- for (let j = 1; j < arrayLength; j++) {
+ for (let j = i + 1; j < arrayLength; j++) {
5
const a = arrayToCompare[i];
6
const b = arrayToCompare[j];
7
if (a + b === nextNumber && a !== b) return true;
0 commit comments