Skip to content

122. Best Time to Buy and Sell Stock II#50

Open
colorbox wants to merge 1 commit into
mainfrom
122
Open

122. Best Time to Buy and Sell Stock II#50
colorbox wants to merge 1 commit into
mainfrom
122

Conversation

@colorbox

Copy link
Copy Markdown
Owner

No description provided.

Comment thread 122/step1.cpp

全探索→DP→貪欲法という順序を進んでとければ良かったが、DPの構造を見出せなかったのでstep2以降で練習していく
自分の良くない思考の癖みたいなのをLLMとのやり取りの中で見つけられたので次回以降は改善していきたい
ボトムアップで考えず、ひらめきによるショートカットを試みようとする悪癖があり、それが出るとコードが書けなくてハマってしまう。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

パソコンで書く前に
コードを含めて紙に書いてみるのもいいと思いました。

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.

なるほど、コメントありがとうございます。
脳内メモリから溢れないようにするのに手書きは良さそうですね。

Comment thread 122/step1.cpp
Time complexity: O(n)
Space complexity: O(1)

計算ミスをしてしまい、1円でも特になるなら常に売買してよい、という条件を見落としてしまう。

@h-masder h-masder Jun 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Leetcode上でアクセプトされることを意識しすぎないことが大事だと思います。なんとなくですが、以下のことを意識するとよいと思いました。

・コードを書く前に実装したいことや入出力を確認すること(決まっていないものは自分で決めていいです)
・どんなコードを書けばいいか簡単に説明を入れること
・実行時間はどれくらいかを見積もること
・(テストケースを自分で書いてみること)

@colorbox colorbox Jun 22, 2026

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.

なるほど、コメントありがとうございます、参考にします。

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