Find all values that appear in the array as a run of equal numbers whose total length matches the value itself.
You are given an array of integers. A value is considered interesting if it appears in the array in one or more contiguous blocks, and the total number of times that value appears in the whole array is exactly equal to the value itself.
Your task is to output all interesting values in increasing order.
If a number appears multiple times in different consecutive blocks, count all occurrences together. Only the final total frequency matters.
Identify every value such that the array contains exactly occurrences of .
Example 1
Input
7 4 5 4 5 4 5 5
Output
2 4 5
Explanation
The value 4 appears exactly 4 times, and the value 5 appears exactly 5 times. Both are interesting.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.