Hey! My name is Tomas. Thanks for checking out my channel.
LeetCode 1. Two Sum: https://leetcode.com/problems/two-sum/
Solution: https://github.com/R-Tomas-Gonzalez/github/tree/main/0001-two-sum
Time Complexity Resource: https://leetcode.com/explore/interview/card/cheatsheets/720/resources/4725/
Example 1
• create a nested for loop
• first loop keeps track of the first number
• second loop keeps track of the second
Example 2
• instead of trying to find two numbers that equal the target
• we're going to keep track of each num and store it in the map, with it's index
• then, we're going to check if the diff is already in the map
• and if it is, we're going to return an arr with map[diff] value, and our current index
• Connect with me on LinkedIn: https://www.linkedin.com/in/rtomasgonzalez/
Happy Coding!
Download
0 formats
No download links available.
How I solved LeetCode 1. Two Sum in JavaScript | NatokHD