Skip to content

Conversation

@akmhmgc
Copy link
Owner

@akmhmgc akmhmgc commented Sep 25, 2025

解いた問題

122. Best Time to Buy and Sell Stock II

使用言語

Ruby

次に解く問題

139. Word Break

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

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 の方が素直かなと個人的には思いました。

end
```

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

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.

4 participants