Skip to content

121. Best Time to Buy and Sell Stock#40

Open
ryoooooory wants to merge 2 commits intomainfrom
task/121
Open

121. Best Time to Buy and Sell Stock#40
ryoooooory wants to merge 2 commits intomainfrom
task/121

Conversation

@ryoooooory
Copy link
Copy Markdown
Owner

Copy link
Copy Markdown

@huyfififi huyfififi left a comment

Choose a reason for hiding this comment

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

読みやすかったです!特に引っかかるところはありませんでした

return 0;
}
int maxProfit = 0;
for (int i = 0; i < prices.length; i++) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: 私だったらijsell_i, buy_iとしてもう少し情報を乗せるかなと思いました。

The Art of Readable Codeにそんなことが載っていたな...と思い読み返してみたところ、

...But sometimes there are better iterator names than i, j, and k.

とし、3重ループの例を挙げて

if (clubs[i].members[k] == users[j])

とするよりも

if (clubs[club_i].members[member_i] == users[user_i])

とした方がわかりやすいと指摘されていました。Best Time to Buy and Sell Stockの場合同じpricesにアクセスしているので、The Art of Readable Codeの例とは若干設定が異なるのですが、参考まで。

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