CSES Problemset/Sorting and Searching
Distinct Values Subarrays II
#2428Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopGiven an array of integers, your task is to calculate the number of subarrays that have at most distinct values.
Input
The first input line has two integers and .
The next line has integers : the contents of the array.
Output
Print one integer: the number of subarrays.
Constraints
Sample Test Cases (1)
Example 1ID: sample-1
Input
5 2 1 2 3 1 1
Expected Output
10
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
5 2 1 2 3 1 1
Expected Output
10