class Solution:
def sumOddLengthSubarrays(self, arr: List[int]) -> int:
ans = sum(arr)
for i in range(0, len(arr)):
for j in range(3, len(arr)+1, 2):
if i+j<len(arr)+1:
ans+=sum(arr[i:i+j])
return ans
网友评论