See this problem in the group, do it with python,
defFind (array): v_sum= Greatest =0 forAinchArray:v_sum+=a v_sum= 0ifV_sum < 0ElseV_sum Greatest= V_sumifV_sum > GreatestElseGreatestifV_sum = =0:greatest=array[0] forAincharray:greatest= AifGreatest < AElseGreatestPrintgreatestarr1= [1, 2,-4, 3, 3]find (arr1)
Idea: from left to right sliding scale, if the v_sum is positive, you can continue to add to the back of the element,
If the v_sum has been negative, it is necessary to clear the original v_sum to 0, if v_sum clear 0 and greatest is not one by one synchronous,
finally, comparing greatest and v_sum, it is important to note that if the list is full of negative values, then the value of greatest is to iterate over the following table to take the maximum Value.
Enter an array of shapes with positive and negative numbers in the Array. One or more consecutive integers in an array make up a sub-array, each of which has a and. The maximum value for the and of all Sub-arrays. Requires a time complexity of O (n)