1011_capacity_to_ship_packages_within_d_days#44
Open
dxxsxsxkx wants to merge 1 commit into33_search_in_rotated_sorted_arrayfrom
Open
1011_capacity_to_ship_packages_within_d_days#44dxxsxsxkx wants to merge 1 commit into33_search_in_rotated_sorted_arrayfrom
dxxsxsxkx wants to merge 1 commit into33_search_in_rotated_sorted_arrayfrom
Conversation
mamo3gr
reviewed
Mar 13, 2026
| while (min_capacity < max_capacity) { | ||
| int mid = min_capacity + (max_capacity - min_capacity) / 2; | ||
|
|
||
| // Can you ship `weights` within `days` with `capacity`? |
There was a problem hiding this comment.
このコメントも shipWithinDays と同じフォーマットで、関数の定義以下に書くと統一感が出ると思いました。
この箇所では命名が良いので、コメントは無くても伝わりました。
mamo3gr
reviewed
Mar 13, 2026
| } | ||
| private: | ||
| bool canShip(std::vector<int>& weights, int days, int capacity) { | ||
| int days_spent = 1; |
There was a problem hiding this comment.
_used よりも _spent の方がより分かりやすいですね 👍 細かいところの改善も検討されていて素晴らしいと思いました。
mamo3gr
reviewed
Mar 13, 2026
|
|
||
| - [参照](https://github.com/potrue/leetcode/pull/44/changes#r2276124905) | ||
|
|
||
| `std::accumulate` の代わりに [`std::reduce`](https://cpprefjp.github.io/reference/numeric/reduce.html)。C++17から。どっちがいいかは正直分からず。 |
There was a problem hiding this comment.
C++に不慣れな私としては、accumulate の方が加算なのだなと想像しやすかったです。reduce は「たぶんデフォルトのオペレーションが加算なんだろうけど、リファレンスを見に行くか」となりました。
|
いずれも読みやすかったです! |
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/capacity-to-ship-packages-within-d-days/description/
次の問題
50. Pow(x, n)