Tap here to switch tabs
Problem
Submissions

Problem: Sum of Variable Length Subarrays

med
30 min
Try to solve the Sum of Variable Length Subarrays problem.

Statement

You are given an integer array nums of size n.

For each index i where 0≤0 \leq i << n, consider the subarray nums[start ... i] where start =max⁡(0,= \max(0, i −- nums[i])).

Return the total sum of the elements of all such subarrays.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Variable Length Subarrays

med
30 min
Try to solve the Sum of Variable Length Subarrays problem.

Statement

You are given an integer array nums of size n.

For each index i where 0≤0 \leq i << n, consider the subarray nums[start ... i] where start =max⁡(0,= \max(0, i −- nums[i])).

Return the total sum of the elements of all such subarrays.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤1000\leq 1000