Skip to content

122. Best Time to Buy and Sell Stock II - #33

Open
akmhmgc wants to merge 1 commit into
mainfrom
122
Open

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

Conversation

@akmhmgc

@akmhmgc akmhmgc commented Sep 25, 2025

Copy link
Copy Markdown
Owner

解いた問題

122. Best Time to Buy and Sell Stock II

使用言語

Ruby

次に解く問題

139. Word Break

@akmhmgc akmhmgc added the ruby label Sep 25, 2025
Comment thread 122/step3.md
def max_profit(prices)
max_profit = 0
prices.each_cons(2) do |prev_price, current_price|
next unless current_price > prev_price

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

next if current_price <= prev_price の方が素直かなと個人的には思いました。

Comment thread 122/step1.md
end
```

これもRubyっぽくてありかもしれない。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ruby っぽいってこんな感じなのですね。。
勉強になります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants