Random query problem maths

Can someone plz explain the test case? what is the question asking?

Hello @govilayush, the test case is
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
I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks :slight_smile:
Happy Coding !!