Skip to content

Commit 04a3e81

Browse files
hot9cupsignacio-chiazzo
authored andcommittedOct 9, 2022
EsLint and Tests fix
- A lot of files had Linting issues. Used EsLint to fix all the troublesome files. - Fixed the tests that were failing. Node Tests.js should run just fine now!
1 parent c02cf2c commit 04a3e81

File tree

91 files changed

+449
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+449
-446
lines changed
 

‎LeetcodeProblems/Algorithms/2Sum.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var twoSum = function (nums, target) {
3232
let map = {};
3333
for (let i = 0; i < nums.length; i++) {
3434
const sum = target - nums[i];
35-
if (map[parseInt(sum)] != 0) {
35+
if (sum in map) {
3636
return [map[sum], i];
3737
} else {
3838
map[nums[i]] = i;
@@ -43,8 +43,8 @@ var twoSum = function (nums, target) {
4343
//Another method
4444
var twoSum2 = function (nums, target) {
4545
for (let i = 0; i < nums.length; i++) {
46-
for (let j = i + 1; j < nums.length; i++) {
47-
if (nums[1] + nums[j] === target) {
46+
for (let j = i + 1; j < nums.length; j++) {
47+
if (nums[i] + nums[j] === target) {
4848
return [i, j];
4949
}
5050
}

‎LeetcodeProblems/Algorithms/3SumClosest.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ Constraints:
3030
* @param {number} target
3131
* @return {number}
3232
*/
33-
var threeSumClosest = function(nums, target) {
33+
var threeSumClosest = function(nums, target) {
3434
let mid = 1;
3535
let right = nums.length - 1;
3636
let currentSum = nums[0] + nums[mid] + nums[right];
3737
let closest = currentSum;
3838

39-
nums.sort(function(a,b) {return a - b})
39+
nums.sort(function(a,b) {return a - b;});
4040

4141
for(var left = 0 ; left < nums.length - 1; left++) {
42-
mid = left + 1;
43-
right = nums.length - 1;
42+
mid = left + 1;
43+
right = nums.length - 1;
4444

45-
while(mid < right) {
46-
currentSum = nums[left] + nums[mid] + nums[right];
45+
while(mid < right) {
46+
currentSum = nums[left] + nums[mid] + nums[right];
4747

48-
if(Math.abs(target - currentSum) < Math.abs(target - closest)) {
49-
closest = currentSum;
50-
}
48+
if(Math.abs(target - currentSum) < Math.abs(target - closest)) {
49+
closest = currentSum;
50+
}
5151

52-
if(currentSum > target) {
53-
right--;
54-
} else {
55-
mid++;
56-
}
52+
if(currentSum > target) {
53+
right--;
54+
} else {
55+
mid++;
5756
}
57+
}
5858
}
5959

6060
return closest;

0 commit comments

Comments
 (0)
Please sign in to comment.