@@ -0,0 +1,577 @@
+public class Solution %7B%0A  // Running time is O(n) and space complexity is O(1).%0A  // It is essentially problem of running sum with max subarray sum, we just need to increase sum%0A  // until it is negative and reset it. Profit keeps track of total non-negative sum we captured.%0A  public int maxProfit(int%5B%5D prices) %7B%0A    int profit = 0;%0A    int curr = 0;%0A    for (int i = 1; i %3C prices.length; i++) %7B%0A      curr += prices%5Bi%5D - prices%5Bi - 1%5D;%0A      if (curr %3C 0) %7B%0A        curr = 0;%0A      %7D%0A      if (curr %3E profit) %7B%0A        profit = curr;%0A      %7D%0A    %7D%0A    return profit;%0A  %7D%0A%7D%0A

add buy-sell-stock solution