You are given a string s made only of the upper case letters A and B. Let n be its length. For an integer k, a pair of indices (i,j) is a k-inversion when 1≤i<j≤n, s[i]=B, s[j]=A, and j−i=k.
Take the string BABA. It has two 1-inversions and one 3-inversion, and it has no 2-inversions.

For each k from 1 to n−1, report the number of k-inversions in s.