2913. Subarrays Distinct Element Sum of Squares I
You are given a 0-indexed integer array
nums.The distinct count of a subarray of
numsis defined as:
- Let
nums[i..j]be a subarray ofnumsconsisting of all the indices fromitojsuch that0 <= i <= j < nums.length. Then the number of distinct values innums[i..j]is called the distinct count ofnums[i..j].Return the sum of the squares of distinct counts of all subarrays of
nums.A subarray is a contiguous non-empty sequence of elements within an array.
1 | class Solution { |