Skip to content

373 find k pairs with smallest sums#11

Open
MA-yo-TA wants to merge 3 commits into
mainfrom
373-Find-K-Pairs-with-Smallest-Sums
Open

373 find k pairs with smallest sums#11
MA-yo-TA wants to merge 3 commits into
mainfrom
373-Find-K-Pairs-with-Smallest-Sums

Conversation

@MA-yo-TA

Copy link
Copy Markdown
Owner

Comment on lines +18 to +22
index2 += 1
if index2 < len(nums2):
heapq.heappush(
candidates, (nums1[index1] + nums2[index2], index1, index2)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

index2を上書きすると,後続のコードの意図がわかりづらくなると感じました.
(自分のコードも見返して同じ問題がありそうでしたが)

nextSmallestIndex程度の命名にしてもよいかもしれませんが,あるいは,そのまま index2+1 と書いてもいいかもしれません.これは趣味の範囲な気がします

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ありがとうございます。出現箇所が三箇所あるので何か変数でおきたいなと思っていたところなので、 (長いですが)new_candidate_index2 とかが個人的にはしっくりくるかなと思いました。

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