StockBuyAndSell { public int maxProfitII(int[] prices) { int max = 0; if (prices.length > 1) { for (int i = 1; i < prices.length; i++) { if (prices[i] > prices[i - 1]) { max += prices[i] - prices[i - 1]; } } } 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 = "stocksII") public void testmaxProfitII(int[] stocks, int maxProfit) { assertEquals(maxProfit, new StockBuyAndSell().maxProfitII(stocks)); }