diff --git a/bestTimeToBuyStocksII.java b/bestTimeToBuyStocksII.java new file mode 100644 index 0000000..c689011 --- /dev/null +++ b/bestTimeToBuyStocksII.java @@ -0,0 +1,17 @@ +class Solution { + public int maxProfit(int[] prices) { + int minL = prices[0]; + int maxL = prices[0]; + int profit = 0; + + for(int i =1; i prices[i-1]) + maxL = prices[i]; + } + if(maxL != minL) profit += maxL - minL; + return profit; + } +} \ No newline at end of file