Get Mean Rank Count
Problem Overview
- Given rank, a permutation of 1..n, compute for each x in 1..n how many contiguous subarrays have mean rank exactly x.
- Input: rank[1..n], 1 ≤ n ≤ 10^3, all distinct; Output: int[n] where the i-th entry is the count for mean i.
- Context: Groups represent students with consecutive roll numbers in an Amazon Academy scholarship test.
- Source: Asked in Amazon interviews; this is a coding interview problem and a common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
