Skip to content

1. Two Sum.md #10

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

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

1. Two Sum.md #10

wants to merge 1 commit into from

Conversation

katataku
Copy link
Owner

@katataku katataku commented Dec 6, 2024

num_to_index[target - num] = i
```

最後に気づいたけど、`num_to_index`より`complement_to_index`の方が、より適切な名前かもしれない。

Choose a reason for hiding this comment

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

かたおかさんの実装だとそんな気がします。個人的にはnum_to_indexにはnumとそのindexを入れて、要素を取得する際にtarget - numでアクセスするほうが自然なようには思います。

- https://github.com/tarinaihitori/leetcode/pull/11
- https://github.com/haniwachann/leetcode/pull/2
- https://github.com/philip82148/leetcode-arai60/pull/1

Copy link

Choose a reason for hiding this comment

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

入力を sort をして頭と尻尾から探していくという手もあるように思います。

Copy link

@philip82148 philip82148 left a comment

Choose a reason for hiding this comment

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

(コメントされている点以外は)いいと思います!

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.

4 participants