* 设置 res 变量为0
func maxProfit(prices []int) int { res := 0 low := 1<<31 - 1 for i := 0; i < len(prices); i++ { diff := prices[i] - low if diff > res { res = diff } if diff <= 0 { low = prices[i] } } return res }