Go Max Profit
func maxProfit(a []int) int {
	price := a[0]
	profit := 0

	for _, v := range a {
		if v < price {
			price = v
		}
		if v-price > profit {
			profit = v - price
		}
	}

	return profit
}

This tracks the lowest buy price seen so far and updates the best profit as it scans the prices once.