Tap here to switch tabs
Problem
Submissions

Problem: Subarrays Distinct Element Sum of Squares II

Try to solve the Subarrays Distinct Element Sum of Squares II problem.

Statement

You are given a 00 indexed integer array nums.

The distinct count of a subarray of nums is defined as the number of unique elements present in that subarray.

Return the sum of the squares of distinct counts across all subarrays of nums.

Since the answer may be very large, return it modulo 109+710^9 + 7.

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: Subarrays Distinct Element Sum of Squares II

Try to solve the Subarrays Distinct Element Sum of Squares II problem.

Statement

You are given a 00 indexed integer array nums.

The distinct count of a subarray of nums is defined as the number of unique elements present in that subarray.

Return the sum of the squares of distinct counts across all subarrays of nums.

Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

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

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