Skip to content

Commit 409758a

Browse files
authored
Merge pull request vJechsmayr#73 from psalmfill/al-two-sum
Algorithm For TwoSum
2 parents 08421af + d296a3b commit 409758a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎OtherAlgorithms/TwoSum.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function twoSum(num_arr, target) {
2+
var result = [];
3+
for (var i = 0; i < num_arr.length; i++) {
4+
for (var j = i + 1; j < num_arr.length; j++) {
5+
if (num_arr[i] + num_arr[j] === target) {
6+
result.push(i);
7+
result.push(j);
8+
}
9+
}
10+
}
11+
return result;
12+
}
13+
module.exports = twoSum;

0 commit comments

Comments
 (0)