#3804

Number of Centered Subarrays

medium · 66.9% accepted · 74 likes · top 73%

array · hash table · enumeration

Description

You are given an integer array nums.

A subarray of nums is called centered if the sum of its elements is equal to at least one element within that same subarray.

Return the number of centered subarrays of nums.

Solution