Skip to content

Commit cce9aea

Browse files
ongchignacio-chiazzo
ongch
authored andcommitted
fix readme and add test
1 parent 644f7e9 commit cce9aea

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

LeetcodeProblems/Algorithms/2Sum.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Output: [0,1]
3232
let map ={};
3333
for(let i=0;i<nums.length;i++){
3434
const sum = target-nums[i];
35-
if(map[parseInt(sum)] != void 0){
35+
if(map[parseInt(sum)] != 0){
3636
return [map[sum], i];
3737
} else{
3838
map[nums[i]] = i;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const assert = require('assert');
2+
const twoSum = require('../../LeetcodeProblems/Algorithms/2Sum').twoSum;
3+
4+
var test = function () {
5+
assert.deepEqual([0,1], twoSum([2,7,11,15], 9));
6+
assert.deepEqual([1,2], twoSum([3,2,4], 6));
7+
assert.deepEqual([0,1], twoSum([3,3], 6));
8+
}
9+
10+
module.exports.test = test;
11+

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ To run a specific problem in your console run `node <problem_file_path>` (e.g.
7878
| [Binary Gap ](/LeetcodeProblems/Algorithms/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ |
7979
| [Binary Gap ](/LeetcodeProblems/Algorithms/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ |
8080
| [Majority Element](/LeetcodeProblems/Algorithms/Majority_Element.js) | Easy | https://leetcode.com/problems/majority-element/ |
81-
| [Two Sum](/LeetcodeProblems/Algorithms/2Sum.js) | Easy | https://leetcode.com/problems/two-sum/ |
81+
| [Two Sum](/LeetcodeProblems/Algorithms/2Sum.js) | Easy | https://leetcode.com/problems/two-sum/ |
8282
| [Tic Tac Toe ](/LeetcodeProblems/Algorithms/Tic_Tac_Toe.js) | | |
8383
| [Permutations With Duplicates ](/LeetcodeProblems/Algorithms/Permutations_With_Duplicates.js) | | |
8484
| [Deletion Distance](/LeetcodeProblems/Algorithms/Deletion_Distance.js) | | |

0 commit comments

Comments
 (0)