Skip to content

Commit 3dde3ef

Browse files
committed
✏️ Fix: #219
1 parent 0a1dec3 commit 3dde3ef

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

two-sum/jangwonyoon.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ var twoSum = function(nums, target) {
77
const length = nums.length - 1;
88

99
for (let i = 0; i < length; i++) {
10-
for (let j = length; j > 0; j--) {
10+
for(let j = length; j > 0; j--) {
1111
const sum = nums[i] + nums[j];
1212

13-
if (sum === target) {
14-
return [i, j];
13+
if (i !== j) {
14+
if (sum === target) {
15+
return [i , j];
16+
}
1517
}
1618
}
1719
}
18-
};
20+
};

0 commit comments

Comments
 (0)