Sum of Odd Length Subarrays
Calculate the total sum of all contiguous subarrays with odd length. Use the contribution formula: for each element at index i, count how many odd-length subarrays include it, multiply by its value, and sum.
Calculate the total sum of all contiguous subarrays with odd length. Use the contribution formula: for each element at index i, count how many odd-length subarrays include it, multiply by its value, and sum.