121. 买卖股票的最佳时机
func maxProfit(prices []int) int {
max := 0
left := 0
for i:=0; i<len(prices); i++ {
dif := prices[i]-prices[left]
if dif > max {
max = dif
}
if dif < 0 {
left = i
}
}
return max
}

浙公网安备 33010602011771号