373 find k pairs with smallest sums#11
Open
MA-yo-TA wants to merge 3 commits into
Open
Conversation
miyataka
reviewed
Jun 15, 2026
Comment on lines
+18
to
+22
| index2 += 1 | ||
| if index2 < len(nums2): | ||
| heapq.heappush( | ||
| candidates, (nums1[index1] + nums2[index2], index1, index2) | ||
| ) |
There was a problem hiding this comment.
index2を上書きすると,後続のコードの意図がわかりづらくなると感じました.
(自分のコードも見返して同じ問題がありそうでしたが)
nextSmallestIndex程度の命名にしてもよいかもしれませんが,あるいは,そのまま index2+1 と書いてもいいかもしれません.これは趣味の範囲な気がします
Owner
Author
There was a problem hiding this comment.
ありがとうございます。出現箇所が三箇所あるので何か変数でおきたいなと思っていたところなので、 (長いですが)new_candidate_index2 とかが個人的にはしっくりくるかなと思いました。
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.
この問題:https://leetcode.com/problems/find-k-pairs-with-smallest-sums/
次の問題:https://leetcode.com/problems/two-sum/