Skip to content

Commit 42a4f64

Browse files
committed
refactor Best Time to Buy and Sell Stock
1 parent d743878 commit 42a4f64

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

go/best_time_to_buy_and_sell_stock.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
package main
33

44
func maxProfit(prices []int) int {
5-
minPrice, maxProfit := prices[0], 0
5+
minPrice, maxValue := prices[0], 0
66
for _, price := range prices {
77
minPrice = min(minPrice, price)
8-
maxProfit = max(maxProfit, price-minPrice)
8+
maxValue = max(maxValue, price-minPrice)
99
}
10-
return maxProfit
10+
return maxValue
1111
}

0 commit comments

Comments
 (0)