Skip to content

Commit

Permalink
Merge pull request #2 from Meldiron/master
Browse files Browse the repository at this point in the history
Added solition for #1 in Javascript
  • Loading branch information
sashaaero committed Oct 10, 2019
2 parents bccf0d6 + 6aa97ff commit 872b764
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions leet_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// https://leetcode.com/problems/two-sum/submissions/
// Runtime: 112 ms, faster than 37.73% of JavaScript online submissions for Two Sum.

/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var twoSum = function(nums, target) {
for(let i = 0; i < nums.length; i++) {
for(let y = i + 1; y < nums.length; y++) {
if(nums[i] + nums[y] === target) {
return [i, y];
}
}
}
};

0 comments on commit 872b764

Please sign in to comment.