public int maxProfit(int[] prices) {
        int  profit =0;
        if(prices.length == 0)
            return 0;
        int up = prices[0];
        int low = prices[0];
        for (int i = 0; i < prices.length ;i++ ){
            if(prices[i] > up){
                up = prices[i];
                profit = Math.max(up- low,profit);
            }

            else if(prices[i] < low) {
                low = prices[i];
                up = low;
            }
        }
        return profit;
    }