Tap here to switch tabs
Problem
Submissions

Problem: Sum of Consecutive Subarrays

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

Statement

Given an integer array nums, return the sum of all elements across all consecutive subarrays.

A subarray is a contiguous sequence of elements within an array. A subarray is consecutive if every adjacent pair of elements has a difference of 11, and all elements in the subarray are either strictly increasing or strictly decreasing. Subarrays of length 11 are always consecutive.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Consecutive Subarrays

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

Statement

Given an integer array nums, return the sum of all elements across all consecutive subarrays.

A subarray is a contiguous sequence of elements within an array. A subarray is consecutive if every adjacent pair of elements has a difference of 11, and all elements in the subarray are either strictly increasing or strictly decreasing. Subarrays of length 11 are always consecutive.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5