abhisek247767 / LeetCode2024-6Companies30Days

Make your first Pull Request on Hacktoberfest 2024. Don't forget to spread love and if you like give us a ⭐️
33 stars 54 forks source link

πŸ“ƒ: Two Sum #123

Open MuhammadBabarWaseem opened 2 hours ago

MuhammadBabarWaseem commented 2 hours ago

🟒 Title : Two Sum 🟒 Programming language : JavaScript 🟒 Objective : The objective of the "Two Sum" problem is to determine the indices of two numbers in a given array that add up to a specified target value. The solution must return the indices of these two numbers, ensuring that each input would have exactly one solution, and the same element cannot be used twice. 🟒 Summary : The "Two Sum" problem is a classic algorithmic challenge commonly encountered in coding interviews and competitive programming. Given an array of integers and a target integer, the goal is to find the indices of two numbers such that their sum equals the target.

The most efficient approach involves using a hash map to store the numbers encountered and their corresponding indices as the array is traversed. This allows for a single-pass solution with a time complexity of O(n) and a space complexity of O(n). By checking for the existence of the complement (target minus the current number) in the hash map, the algorithm can quickly identify the required pair of indices, making it both time-efficient and easy to implement.


βœ… Details to Include When Taking the Issue: Name : MuhammadBabarWaseem


Happy Contributing! πŸš€

Wishing you all the best on your open source journey😍. Enjoy! 😎

github-actions[bot] commented 2 hours ago

πŸ‘‹ Thanks for opening this issue! First please star the repository and follow me in github. We appreciate your feedback and will look into it as soon as possible.

MuhammadBabarWaseem commented 2 hours ago

@abhisek247767 can you please assign this to me? with hacktoberfest labels?