Skip to content

Commit 525a603

Browse files
committed
[refactor] Small edit in Q15 maxSubArraySumCircular
1 parent 143142d commit 525a603

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

platform-problems/leetcode/may-2020-leetcoding-challenge/15-LeetCode-maxSubarraySumCircular.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
MaxSubArray sum of a circular array = max(MaxSubArray sum, Sum - MinSubArray sum) <-- to delete the negative link
3131
'''
3232

33+
3334
class Solution(object):
3435
def maxSubArraySumCircular(self, A):
3536
"""
@@ -38,7 +39,7 @@ def maxSubArraySumCircular(self, A):
3839
"""
3940
if len(A) == 0:
4041
return 0
41-
42+
4243
currMax, maxSum, currMin, minSum = A[0], A[0], A[0], A[0]
4344
sumArr = sum(A)
4445
for i in range(1, len(A)):
@@ -47,10 +48,10 @@ def maxSubArraySumCircular(self, A):
4748
maxSum = max(maxSum, currMax)
4849
currMin = min(n, currMin + n)
4950
minSum = min(minSum, currMin)
50-
51+
5152
print(sumArr, minSum, maxSum)
5253
# because we have to find the maximum possible sum of a non-empty SubArray of A
5354
if sumArr == minSum:
5455
return maxSum
55-
56+
5657
return max(sumArr - minSum, maxSum)

0 commit comments

Comments
 (0)