feat:s oivjsovji
This commit is contained in:
11
pkg/best_time_to_buy_and_sell_stock/main.go
Normal file
11
pkg/best_time_to_buy_and_sell_stock/main.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package besttimetobuyandsellstock
|
||||
|
||||
func MaxProfit(prices []int) int {
|
||||
buy, sell := 1_000_000_000, 0
|
||||
|
||||
for _, price := range prices {
|
||||
buy, sell = min(buy, price), max(sell, price-buy)
|
||||
}
|
||||
|
||||
return sell
|
||||
}
|
||||
Reference in New Issue
Block a user