@@ -0,0 +1,585 @@
+package leetcode.best_time_to_buy_and_sell_stock_ii;%0A%0Apublic class Solution %7B%0A%09public int maxProfit(int%5B%5D prices) %7B%0A        int buy = 0;%0A        int profit = 0;%0A        for(int i = 1; i %3C= prices.length; i++)%7B%0A            if(i == prices.length %7C%7C prices%5Bi%5D %3C prices%5Bi - 1%5D)%7B%0A                profit += prices%5Bi - 1%5D - prices%5Bbuy%5D;%0A                buy = i;%0A            %7D%0A        %7D%0A        return profit;%0A    %7D%0A%09%0A%09public static void main(String%5B%5D args)%7B%0A%09%09Solution sol = new Solution();%0A%09%09System.err.println(%22%22 + sol.maxProfit(new int%5B%5D%7B3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6%7D));%0A%09%7D%0A%7D%0A

Add java solution for 122. Best Time to Buy and Sell Stock II