1
2
3
4
5
6
7
|
class Solution:
def sumOddLengthSubarrays(self, arr: List[int]) -> int:
ans=0
for i in range(len(arr)):
for j in range(i, len(arr),2):
ans+=sum(arr[i:j+1])
return ans
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode 1614. Maximum Nesting Depth of the Parentheses (0) | 2021.08.31 |
---|---|
Leetcode 1979. Find Greatest Common Divisor of Array (0) | 2021.08.31 |
Leetcode 1720. Decode XORed Array (0) | 2021.08.31 |
Leetcode 682. Baseball Game (0) | 2021.08.30 |
Leetcode 1441 Build an Array with Stack Operations (0) | 2021.08.30 |
댓글