StockBuyAndSell { public int maxProfitI(int[] prices) { int max = 0; if (prices.length > 1) { int low = prices[0]; for (int i = 1; i < prices.length; i++) { if (prices[i] < low) { low = prices[i]; } else { int p = prices[i] - low; if (p > max) { max = p; } } } } return max; }  int maxProfitI(int[] prices); int maxProfitII(int[] prices); int maxProfitIII(int[] prices); int maxProfitIV(int k, int[] prices); int maxProfitWithCooldown(int[] prices); int maxProfitWithTransactionFee(int[] prices, int fee);  }
@Test(dataProvider = "stocksI") public void testmaxProfitI(int[] stocks, int maxProfit) { assertEquals(maxProfit, new StockBuyAndSell().maxProfitI(stocks)); }