Max Contiguous Subarray

108 views 7:09 am 0 Comments August 12, 2023

Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list. Input

The input will contain space-separated integers, denoting the elements of the list. Output

The output should be an integer. Explanation

For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,

Tags: , , , , , , ,