SEAEQ - Editorial

Hi

A great question followed by a nicer editorial. It would be great if you could tell me why exactly do we need to take into account the number of starting positions and the number of ways of arranging the remaining elements?

Sum-DP[d][E] will give me total number of permutations of length d that has at-most E inversions.

Total number of distinct pairs, (l,r) that can be selected from two arrays( where r=l+d-1) is basically similar to total number of ways of selecting d out of n elements, given by C[n][d]*C[n][d].

Won’t the product of the above two suffice?

Thanks And Regards

LoneCoder

Author’s solution gets WA :smiley: