Conversation
mamo3gr
reviewed
Jan 10, 2026
| self, nums1: List[int], nums2: List[int], k: int | ||
| ) -> List[List[int]]: | ||
| candidate = [] | ||
| added_indice = set() |
There was a problem hiding this comment.
add はsetの操作なので、実際の意味にできるとよりよいのではないでしょうか。すぐに思いついたのは used, あるいは検証するという意味で checked, tested などj
Owner
Author
There was a problem hiding this comment.
ご指摘ありがとうございます。
毎回実際の意味にできておらずデータ構造への操作の名前にしてしまうよう癖づいてしまっていることを認識できました。
候補を挙げていただいた中だと特にcheckedがしっくりきました。
mamo3gr
reviewed
Jan 10, 2026
| enqueue_if_valid_and_not_added(0, 0) | ||
|
|
||
| while len(smallest_pairs) < k: | ||
| _sum, [n1_index, n2_index] = heapq.heappop(candidate) |
There was a problem hiding this comment.
_ で始まる変数は、内部(未公開)であることを表す慣習があるように思います。予約語との衝突回避なら sum_, 単に無視するなら _, 和であることを示しながら無視するなら sum_ignored などの選択肢もありそうです。
Owner
Author
There was a problem hiding this comment.
元々は無視をしていい変数だが和が入っていますというニュアンスで_sumとしておりました。
sumが入っていることは今回のケースだと意識しなくて良いので今度は_とするようにいたします。
またsumが入っていることをどうしても示したい時はsum_ignoredとするようにします。
oda
reviewed
Jan 11, 2026
| - `空間計算量を求めたあと、実際のどの程度のメモリを使用するか推定されましたでしょうか?もししていないのであれば、推定することをお勧めいたします。推定するには、時間計算量の式に最大サイズを代入し、 1 要素当たりのサイズを掛けてみてください。`. `sys.getsizeof`など勉強になった | ||
| - 自分で言うところのsum_heapは最小値候補なので、`candidates`とした方が良いように思った | ||
| - 自分の命名だと意味が付け加えられていないように感じた | ||
| - `enqueue_if_valid_and_not_visited`確かにわかりやすい |
naoto-iwase
reviewed
Jan 13, 2026
naoto-iwase
left a comment
There was a problem hiding this comment.
stepを経るごとにどんどん読みやすくなるように感じました。
step3のコードで問題ないと思います。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解いた問題
Find K Pairs With Smallest Sums
次に解く問題
Two Sum