public int maxProfit(int[] prices) {
        int profit = 0, min = Integer.MAX_VALUE;
        for(int price : prices){
            min = price < min ? price : min;
            profit = price - min > profit ? price - min : profit;
        }
        return profit;
    }