Skip to content

Commit 538979b

Browse files
authored
Update sum-of-all-odd-length-subarrays.py
1 parent 5ffa8a2 commit 538979b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/sum-of-all-odd-length-subarrays.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def sumOddLengthSubarrays(self, arr):
77
:type arr: List[int]
88
:rtype: int
99
"""
10-
def ceil(a, b):
10+
def ceil_divide(a, b):
1111
return (a+(b-1))//b
1212

1313
# begin\pos |0 i (n-1)
@@ -24,4 +24,4 @@ def ceil(a, b):
2424
# because the number of 1 is always equal to or one more than the number of 0, (always begins with 1010... and alternatively flips)
2525
# so there are ceil((i-0+1)*((len(arr)-1)-i+1)/2) odd length subarrays with x
2626
#
27-
return sum(x * ceil((i-0+1)*((len(arr)-1)-i+1), 2) for i, x in enumerate(arr))
27+
return sum(x * ceil_divide((i-0+1)*((len(arr)-1)-i+1), 2) for i, x in enumerate(arr))

0 commit comments

Comments
 (0)