package ArdenDertatQuestions;

public class LargestContinuousSum {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[] arr = {123,23,-456,78,234,456,345,78,234};
		System.out.println(largestContSum(arr));
	}
	
	public static long largestContSum(int[] arr){
		if(arr.length == 0){
			return 0;
		}
		long maxSum = arr[0];
		long currSum = arr[0];
		for (int i = 1; i < arr.length; i++) {
			System.out.println("--------");
			currSum = Math.max(currSum + arr[i], arr[i]);
			maxSum = Math.max(currSum, maxSum);
			System.out.println(currSum);
			System.out.println(maxSum);
			System.out.println("--------");
		}
		return maxSum;
	}

}
