public class Solution {
    /**
     * 
     * @param prices int整型一维数组 
     * @return int整型
     */
    public int maxProfit (int[] prices) {
        // write code here
        if(prices == null ||prices.length == 1){
            return 0 ;
        }
        int buy = prices[0];
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<prices.length;i++){
            //找到最小 买入点
            buy = Math.min(buy,prices[i]);
            max = Math.max(max, prices[i] - buy);
        }
        return max;
    }
}