-
Notifications
You must be signed in to change notification settings - Fork 65
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
Labels
hacktoberfest
hacktoberfest contributions
Comments
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
https://leetcode.com/problems/two-sum/description/ |
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
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
Given an array of integers
nums
and an integertarget
, 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.
The text was updated successfully, but these errors were encountered: