Skip to content

Added solution for Two Sum Leetcode Problem#12

Open
Rifana-E wants to merge 10 commits intoWeCode-Community-Dev:mainfrom
Rifana-E:rif0215
Open

Added solution for Two Sum Leetcode Problem#12
Rifana-E wants to merge 10 commits intoWeCode-Community-Dev:mainfrom
Rifana-E:rif0215

Conversation

@Rifana-E
Copy link

We iterate through the array.
For each number, calculate the number needed to reach the target.
Check if this complement is already in the dictionary.
If the complement exists in the dictionary, that means we have found our pair.
We return the indices of the two numbers.
If the complement is not found, store the current number in the dictionary.
Continue checking for the rest of the numbers.

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