로딩
요청 처리 중입니다...

JAVA_LeetCode 3427_Sum of Variable Length Subarrays

 JAVA_LeetCode 3427_Sum of Variable Length Subarrays

JAVA_LeetCode 3427_Sum of Variable Length Subarrays 풀이 class Solution { public int subarraySum(int[] nums) { // 하위 배열의 시작지점이 max(0, i - nums[i])이므로, 시작지점을 구해서 i까지의 요소 값을 더해준다. int res = 0, temp = 0; for(int i = 0; i < nums.length; i++){ temp = Math.max(0, i - nums[i]); while(temp <= i){ res += nums[temp]; temp++; } } return res; } } * 출처 https://leetcode.com/problems/sum-of-variable-length-subarrays...