@@ -0,0 +1,1878 @@
+//https://www.hackerrank.com/challenges/maxsubarray%0Aimport java.io.*;%0A%0Apublic class Solution %7B%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    StringBuffer sb = new StringBuffer();%0A    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A    %0A    //For each test case%0A    for(byte T = Byte.parseByte(br.readLine()); T %3E 0; --T)%7B%0A      %0A      //Get input%0A      final int N = Integer.parseInt(br.readLine());%0A      final short A%5B%5D = toShortArray(br.readLine().split(%22 %22), N);%0A      %0A      //Initialize output%0A      int maxSumCont = 0;%0A      int maxSumNonCont = 0;%0A      %0A      //Get maximum value%0A      final short maxVal = max(A, N);%0A      %0A      //If there are no positive values, use max value%0A      if(maxVal %3C 1)%7B%0A        maxSumNonCont = maxSumCont = maxVal;%0A      %0A      //Get max sums%0A      %7D else %7B%0A        maxSumCont = getMaxContiguousSum(A, N);%0A        maxSumNonCont = getMaxNonContiguousSum(A, N);%0A      %7D%0A      %0A      //Print output%0A      sb.append(maxSumCont + %22 %22 + maxSumNonCont + %22%5Cn%22);%0A    %7D%0A    System.out.print(sb);%0A  %7D%0A  %0A  private static int getMaxContiguousSum(final short%5B%5D A, final int N)%7B%0A    int cur = 0;%0A    int sum = 0;%0A    for(int i = 0; i %3C N; ++i)%7B%0A      cur = Math.max(cur + A%5Bi%5D, 0);%0A      sum = Math.max(sum, cur);%0A    %7D%0A    return sum;%0A  %7D%0A  %0A  private static int getMaxNonContiguousSum(final short%5B%5D A, final int N)%7B%0A    int sum = 0;%0A    for(int i = 0; i %3C N; sum += Math.max(A%5Bi++%5D, 0))%7B%7D%0A    return sum;%0A  %7D%0A  %0A  private static short max(final short%5B%5D A, final int N)%7B%0A    short max = Short.MIN_VALUE;%0A    for(int i = 0; i %3C N; ++i)%7B%0A      max = (max %3E A%5Bi%5D) ? max : A%5Bi%5D;%0A    %7D%0A    return max;%0A  %7D%0A  %0A  private static short%5B%5D toShortArray(final String%5B%5D A, final int N)%7B%0A    final short%5B%5D B = new short%5BN%5D;%0A    for(int i = 0; i %3C N; ++i)%7B%0A      B%5Bi%5D = Short.parseShort(A%5Bi%5D);%0A    %7D%0A    return B;%0A  %7D%0A%7D%0A

Create maxsubarray.java