Skip to content

3sum#80

Open
Yuto729 wants to merge 1 commit into
mainfrom
3sum
Open

3sum#80
Yuto729 wants to merge 1 commit into
mainfrom
3sum

Conversation

@Yuto729

@Yuto729 Yuto729 commented Jun 19, 2026

Copy link
Copy Markdown
Owner

解く問題

3sum

次に解く問題

Repository owner deleted a comment from github-actions Bot Jun 19, 2026
Comment thread 3sum/main.md

| 手法 | Time | Space | 重複排除 |
|------|------|-------|--------|
| ハッシュマップ法 | O(n²) | O(n) | タプルを `seen` セットに追加 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ハッシュマップ法、ハッシュセット法という言い方はあまりしないように思います。

Comment thread 3sum/main.md
rest = two_sum_from(i + 1, -nums[i])
for pair in rest:
pair.append(nums[i])
result.append(pair)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

two_sum_from() の中で list を毎回構築しているのがやや無駄に感じました。 nums[i] も two_sum_from() に渡し、直接 result に入れたほうが軽くなると思いました。ただ、定数倍の差しかなく、定数倍の差を気にするのであれば、速い言語で書き直したほうが良さそうだとも思いました。

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.

2 participants