Write a program to find contiguous subarray within a given array of integers which has the largest sum.
Example :
Input:int[] A = {1, 2, -3, -4, 0, 6, 7, 8, 9}
Output: The largest sum of contiguous sub-array: 30
Above answer if 30 because sum of 0 + 6 + 7 + 8 +9 is 30
Input:int[] A = {12, 2, -34, 1, 10, -18, 9}
Output: The largest sum of contiguous sub-array: 12
Above is answer is 14. Because sum of no other contihuous subarray is greater than 14.
Published By : Swapnil M