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

Commits on Oct 20, 2024

  1. Create TwoSum.py

    Two sum problem in python is created successfully and it works greatly
    vippawar1104 authored Oct 20, 2024
    Configuration menu
    Copy the full SHA
    339f12f View commit details
    Browse the repository at this point in the history
  2. Create twosum.py

    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 authored Oct 20, 2024
    Configuration menu
    Copy the full SHA
    dd224b4 View commit details
    Browse the repository at this point in the history