1588. Sum of All Odd Length Subarrays
Easy
Given an array of positive integers arr
, return the sum of all possible odd-length subarrays of arr
.
A subarray is a contiguous subsequence of the array.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= arr.length <= 100
1 <= arr[i] <= 1000
Follow up:
Could you solve this problem in O(n) time complexity?
解題
Runtime: 3 ms, faster than 59.29%
Memory Usage: 2.2 MB, less than 86.73%
Last updated