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

[LeetCode] Two Sum #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[LeetCode] Two Sum #1

wants to merge 1 commit into from

Conversation

danielogen
Copy link
Contributor

@danielogen danielogen commented Jan 11, 2024

This PR solves the LeetCode problem: https://leetcode.com/problems/two-sum/description/

The implementation is borrowed from ChatGPT:
https://chat.openai.com/share/5ed4faed-52c3-45dd-9c6a-1363b3f0dd91

complement = target - num
if complement in num_indices:
return [num_indices[complement], i]
num_indices[num] = i
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your current implementation for the two-sum problem looks efficient, but it doesn't handle the case where no solution is found. The function should return None. See here: https://chat.openai.com/share/f3967d74-3668-4eb4-a547-7bf4ee05d617

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