Couldn’t understand what asking in problem
Problem Clarification
Consider this example:
2
1 2
and answer is 1.50000
Here we need to choose and l and any r from 1 to n
And for every possible l,r if(l > r) then swap them you need to find the distinct nos. in that subarray
So
1
1 2
2 are the subarrays
if l = 1 and r = 1
1 no. of distinct nos. = 1
if l = 1 and r = 2
1 2 no. of distinct nos. = 2
if l = 2 and r = 1
1 2 no. of distinct nos. = 2
if l = 2 and r = 2
2 no. of distinct nos. = 1
So if we sum all the distinct nos. of all the subarrays then it will be 1 + 2 + 2 + 1 = 6
and then divide by 4 as in total we have 4 cases. (we have n^2 cases in total ) n values for l and n values for r
So, 6/4 = 1.5000