Skip to content

1.two sum#1

Open
arahi10 wants to merge 3 commits intomainfrom
1.Two_Sum
Open

1.two sum#1
arahi10 wants to merge 3 commits intomainfrom
1.Two_Sum

Conversation

@arahi10
Copy link
Copy Markdown
Owner

@arahi10 arahi10 commented Feb 22, 2026

問題

https://leetcode.com/problems/two-sum/

成果物所在

1._Two_Sum/memo.mdがステップ1~3までをまとめたmdファイルです. 
そのほかの変更されたファイルはご放念ください.

2. 次に取り組む問題のリンク

https://leetcode.com/problems/search-insert-position

Comment thread 1._Two_Sum/memo.md
Comment on lines +49 to +60
```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
num2idx = {}
for i, num in enumerate(nums):
required = target - num
if required in num2idx:
return [i, num2idx[required]]
num2idx[num] = i
raise ValueError("no two sum solution")

```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

あまり自然言語処理以外のところでtoを2にするのは見ない気がするので、toにしたほうがわかりやすい気がします。(Nand2Tetrisとかはあるので私の感覚がズレてるかもですが)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

to を 2 にしたり、 for を 4 にするのは、十年以上前のハッカー文化を感じます。最近はあまり見かけないように思います。

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.

3 participants