1 /// <summary> 2 /// Solution 3 /// 100/100 4 /// </summary> 5 /// <param name="A"></param> 6 /// <returns></returns> 7 public int solution(int[] A) 8 { 9 if (A.Length <= 1) 10 return 0; 11 int minPrice = A[0]; 12 int maxProfitSofar = 0; 13 for (int i = 1; i < A.Length; i++) 14 { 15 maxProfitSofar = Math.Max(maxProfitSofar, A[i] - minPrice); 16 minPrice = Math.Min(minPrice, A[i]); 17 } 18 return maxProfitSofar; 19 }