diff --git a/array/BestTimeToStockBuySell2.java b/array/BestTimeToStockBuySell2.java new file mode 100644 index 0000000..a276bfc --- /dev/null +++ b/array/BestTimeToStockBuySell2.java @@ -0,0 +1,16 @@ +class Solution { + public int maxProfit(int[] a) { + int profit=0,i; + for(i=0;i 0) + profit=profit+ a[i+1] - a[i]; + } + return profit; + } +}