Skip to content

Commit e1466f5

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

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

go/best_time_to_buy_and_sell_stock.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//lint:file-ignore U1000 Ignore all unused code
22
package main
33

4+
import "math"
5+
46
func maxProfit(prices []int) int {
5-
minPrice, maxValue := prices[0], 0
7+
minPrice, maxValue := math.MaxInt, 0
68
for _, price := range prices {
79
minPrice = min(minPrice, price)
810
maxValue = max(maxValue, price-minPrice)

0 commit comments

Comments
 (0)