Skip to content

Conversation

@hroc135
Copy link
Owner

@hroc135 hroc135 commented Jan 9, 2025

func maxProfit(prices []int) int {
minPrices := make([]int, len(prices))
minPrice := prices[0]
for i := 0; i < len(prices); i++ {

Choose a reason for hiding this comment

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

こちらはindexを0スタートとし、step3はindexを1としているのですが何か意図はございますでしょうか?

Copy link
Owner Author

Choose a reason for hiding this comment

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

特にないです、、こっちもi := 1 としたいところでした

#### 2d
- 2aを逆から見ていくこともできる
- https://github.com/fhiyo/leetcode/pull/38/files#diff-2508181bc4e99cbc345ea1ae774e36744db291b2c450072d0c29b5d0bd029069R28

Choose a reason for hiding this comment

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

前からと後ろ側どちらも実装されているのいいですね。
確認済でしたらすみません。他にも株持ってる状態 or 持ってない状態を用いた解法もございます。
Yoshiki-Iwasa/Arai60@5e3ee8f

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