Tap here to switch tabs
Problem
Submissions

Problem: Number of Centered Subarrays

Number of Centered Subarrays asks you to count contiguous, nonempty subarrays of an integer array whose total sum matches at least one value within them, including negative values.

Statement

Given an integer array nums, return the total number of centered subarrays.

A subarray is considered centered if the sum of all its elements is equal to at least one element contained within that subarray.

A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤500\leq 500

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Centered Subarrays

Number of Centered Subarrays asks you to count contiguous, nonempty subarrays of an integer array whose total sum matches at least one value within them, including negative values.

Statement

Given an integer array nums, return the total number of centered subarrays.

A subarray is considered centered if the sum of all its elements is equal to at least one element contained within that subarray.

A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤500\leq 500

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