Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created TwoSum.py #7945

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Created TwoSum.py #7945

wants to merge 2 commits into from

Conversation

vippawar1104
Copy link

Problem
The requirement is to efficiently find two indices in an array where the corresponding numbers sum to a given target.

Solution
Implemented a Python function that uses a hash map to find the indices of the two numbers that add up to the target in a single pass.

Changes Proposed

Created the function two_sum(nums, target) to perform the computation.
Used a dictionary to store the indices of numbers for quick lookup.
Ensured the function returns indices in an optimal manner.
Other Changes

Added unit tests for various scenarios to verify function correctness.
Updated the documentation to explain the function's usage clearly.

Two sum problem in python is created successfully and it works greatly
Problem
The requirement is to efficiently find two indices in an array where the corresponding numbers sum to a given target.

Solution
Implemented a Python function that uses a hash map to find the indices of the two numbers that add up to the target in a single pass.

Changes Proposed

Created the function two_sum(nums, target) to perform the computation.
Used a dictionary to store the indices of numbers for quick lookup.
Ensured the function returns indices in an optimal manner.
Other Changes

Added unit tests for various scenarios to verify function correctness.
Updated the documentation to explain the function's usage clearly.
@vippawar1104
Copy link
Author

@vippawar1104 Please Star ⭐️ the repo to earn 'hacktober-accepted' label for the event.

@vippawar1104
Copy link
Author

@vippawar1104 Please Star ⭐️ the repo to earn 'hacktober-accepted' label for the event.

done👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant