Skip to content

1. Two Sum#13

Open
xbam326 wants to merge 3 commits into
mainfrom
1
Open

1. Two Sum#13
xbam326 wants to merge 3 commits into
mainfrom
1

Conversation

@xbam326
Copy link
Copy Markdown
Owner

@xbam326 xbam326 commented Jan 10, 2026

問題
Two Sum

次に解く問題
Group Anagrams

- dictの命名でkey_to_valueはとても良いので毎回候補の中に入れるようにしたい
- checked_は今回のような短いコードの場合はすぐわかるので書かなくて良さそう
- step1-2でミスでtupleで返してもLeetCode的にOKになっていた
- 内部的にどういう感じでOK/NGの判定をしているのかイメージしたところfor文で判定してたりするとこのような現象が起こりそうだと思った
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

予想として、順序が違っても正解にしたいので
expected == sorted(actual) とかにしているのではないですかね。

- https://github.com/mamo3gr/arai60/pull/11/files
- 配列の長さが0,1の時エラーを投げてるのはいいと思う
- エラーを返すかNoneを返すか毎回悩む
- `complement`は全く選択肢に出てこなかったので調べた
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

単語を知らないのは仕方がないし、実際の仕事の場面では調べるなどできると思います。
どう考えるか、どういう価値観を持つかを気にしましょう。

return [num_to_index[complemnt], index]
num_to_index[num] = index

return
Copy link
Copy Markdown

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.

3 participants