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

[Solution] -Leetcode Two Sum in python #8

Closed
Petsamuel opened this issue Oct 2, 2023 · 3 comments · Fixed by #11
Closed

[Solution] -Leetcode Two Sum in python #8

Petsamuel opened this issue Oct 2, 2023 · 3 comments · Fixed by #11
Assignees
Labels
hacktoberfest hacktoberfest contributions

Comments

@Petsamuel
Copy link
Contributor

Description

  • The twoSum() method takes two arguments: the input array (nums) and the target sum (target).

  • For each element (num) in the input array, the method calculates the complement (complement) of that element._

  • The method checks if the complement is already in the hash table (container). If it is, then the method returns the indices of the two elements (container[complement] and i).

  • Otherwise, the method adds the element to the hash table (container[num] = i).

DSA Problem

class Solution(object):
    def twoSum(self, nums, target):

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

@Petsamuel Petsamuel added the hacktoberfest hacktoberfest contributions label Oct 2, 2023
Petsamuel added a commit to Petsamuel/30-Days-DSA-Challenge that referenced this issue Oct 2, 2023
@iamdestinychild
Copy link
Owner

kindly provide the link to the problem

Petsamuel added a commit to Petsamuel/30-Days-DSA-Challenge that referenced this issue Oct 2, 2023
Petsamuel added a commit to Petsamuel/30-Days-DSA-Challenge that referenced this issue Oct 2, 2023
Petsamuel added a commit to Petsamuel/30-Days-DSA-Challenge that referenced this issue Oct 2, 2023
@Petsamuel
Copy link
Contributor Author

Petsamuel commented Oct 2, 2023

kindly provide the link to the problem

https://leetcode.com/problems/two-sum/description/
Programinglanguage= Python

@iamdestinychild
Copy link
Owner

Cool

iamdestinychild added a commit that referenced this issue Oct 2, 2023
[Solution] Two Sum in python #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest hacktoberfest contributions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants