import java.util.*;
public class Solution {
/**
*
* @param prices int整型一维数组
* @return int整型
*/
public int maxProfit (int[] prices) {
// write code here
// 找到最小的买点,和最大的差价,卖点只会出现在买点后面
int min = prices[0],max=0;
for(int i=0;i<prices.length;i++){
if(prices[i]<min)min=prices[i];
if(prices[i]-min>max)max=prices[i]-min;
}
return max;
}
}