Count Subarrays With Each Integer Mean

Asked at Amazon · Coding Questions · Difficulty: Medium

`rank` is a permutation of `1..n`. For each `x` in `1..n`, count the contiguous subarrays whose mean equals `x`. Return the list of counts (index `i-1` is the count for `x = i`).

Loading the problem…