'Initializing a variable with INT_MIN in Python 3.8 [duplicate]
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
Solution 1:[1]
we can write INT_MIN by importing sys import sys MIN_INT = -sys.maxsize - 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | likhitha uppala |