-
1588. Sum of All Odd Length Subarrays javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 23:26
class Solution { public int sumOddLengthSubarrays(int[] arr) { int sum = 0; for(int i = 1 ; i <= arr.length; i+= 2){ for (int j = 0 ; j < arr.length - i + 1 ; j++){ //start point for (int k = j ; k < j + i ; k++){ sum += arr[k]; } } } return sum; } }
'LeetCode_Study_Plan > Programming Skills' 카테고리의 다른 글
1672. Richest Customer Wealth java (0) 2022.09.21 283. Move Zeroes java (0) 2022.09.20 1232. Check If It Is a Straight Line java (1) 2022.09.20 496. Next Greater Element I java (0) 2022.09.20 589. N-ary Tree Preorder Traversal java (0) 2022.09.20