Skip to content

Conversation

@TemitopeAgbaje
Copy link
Contributor

I added another method that can be used to solve 2sum.

kindly review, Thank you

Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thanks for contributing

Comment on lines +44 to 51
for (let i = 0; i < nums.length; i++) {
for (let j = i + 1; j < nums.length; i++) {
if (nums[1] + nums[j] === target) {
return [i, j];
}
}
}
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you encapsulate the new solution into a new method named twoSum2?

There are other examples in other files like CoinChange  https://github.com/ignacio-chiazzo/Algorithms-Leetcode-Javascript/blob/08563058f7e93ce1688956cc26d5dc2a98b36d1a/LeetcodeProblems/Algorithms/Coin_Change.js.

Also, could you run the tests for both functions twoSum and twoSum2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright.. i would fix that

@TemitopeAgbaje
Copy link
Contributor Author

I have updated it..
Please review.
Thank you

Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ignacio-chiazzo ignacio-chiazzo merged commit 8f5e2d1 into ignacio-chiazzo:master Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants