@@ -0,0 +1,855 @@
+/**%0A *%09Find the contiguous subarray within an array (containing at least one number) which has the largest sum.%0A *%0A *%09For example, given the array %5B%E2%88%922,1,%E2%88%923,4,%E2%88%921,2,1,%E2%88%925,4%5D,%0A *%09the contiguous subarray %5B4,%E2%88%921,2,1%5D has the largest sum = 6.%0A *%0A *%09Author: matao%09%0A *%0A */%0A%0Apublic class MaximumSubarray %7B%0A%0A%09// sliding window %E6%BB%91%E5%8A%A8%E7%AA%97%E5%8F%A3%0A%09public static int maxSubArray(int%5B%5D nums) %7B%0A        if(nums == null %7C%7C nums.length == 0) %7B%0A            return 0;%0A        %7D%0A        int maxSub = nums%5B0%5D, max = nums%5B0%5D;%0A        for (int i = 1; i %3C nums.length; i++) %7B%0A        %09if(max %3C 0) %7B%0A        %09%09max = 0;%0A        %09%7D%0A        %09max += nums%5Bi%5D;%0A        %09if(max %3E maxSub) %7B%0A        %09%09maxSub = max;%0A        %09%7D%0A        %7D%0A        return maxSub;%0A    %7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D nums1 = %7B-2, 1, -3, 4, -1, 2, 1, -5, 4%7D;%0A%09%09System.out.println(maxSubArray(nums1));%0A%09%7D%0A%7D

add Maximum Subarray solution