class Solution { public int maxProfit(int[] prices) { if(prices.length == 0) return 0; int profit = 0, bought = prices[0]; for(int i=1; i