public static void findMaxSubArray(int[] inputArray) {

        int maxStartIndex = 0;
        int maxEndIndex = 0;
        int maxSum = Integer.MIN_VALUE;

        int cumulativeSum = 0;
        int maxStartIndexUntilNow = 0;

        for (int currentIndex = 0; currentIndex < inputArray.length; currentIndex++) {
            int eachArrayItem = inputArray[currentIndex];

            cumulativeSum += eachArrayItem;

            if (cumulativeSum > maxSum) {
                maxSum = cumulativeSum;
                maxStartIndex = maxStartIndexUntilNow;
                maxEndIndex = currentIndex;
            } else if (cumulativeSum < 0) {
                maxStartIndexUntilNow = currentIndex + 1;
                cumulativeSum = 0;
            }
        }

        //System.out.println("Max sum         : " + maxSum);
//        System.out.println("Max start index : " + maxStartIndex);
//        System.out.println("Max end index   : " + maxEndIndex);

        int maxSum2 = 0;
        for (int currentIndex = 0; currentIndex < inputArray.length; currentIndex++) {
            if (inputArray[currentIndex] > 0)
                maxSum2 += inputArray[currentIndex];
        }
        int max = Integer.MIN_VALUE;
        if (maxSum2 == 0) {
            for (int currentIndex = 0; currentIndex < inputArray.length; currentIndex++) {
                if (inputArray[currentIndex] > max)
                    max = inputArray[currentIndex];
            }
            maxSum2 = max;
        }


        //System.out.println("Max sum non contiguous   : " + maxSum2);
        System.out.println(maxSum + " " + maxSum2);
    }