1

About the code The maximum sum subarray problem is the task of finding a contiguous subarray with the largest sum, within a given one-dimensional array A[1...n] of numbers. Read more: wiki

Pseudo Code

for(each element in array):
    max_ending_here = max_ending_here + a[i]
    if(max_ending_here < a[i])
        max_ending_here = a[i]

    if(max_so_far < max_ending_here)
        max_so_far = max_ending_here

    return max_so_far

My problem This algo is little modified to work for negative integer and that modification is that the max_so_far variable should be initialized with INT_MIN but i cannot find a way to do so in Python

1 Answers1

0

we can write INT_MIN by importing sys import sys MIN_INT = -sys.maxsize - 1

  • No, this is not correct. You can happily make a smaller integer in Python, try just `print(-sys.maxsize - 2)` python integers are arbitrarily sized. – juanpa.arrivillaga May 02 '22 at 06:13