Please can you explain the logic behind this question

Please can you explain the logic behind this question

Hi Vivek
In this question a 1-indexed (indexing starts from 1) array is given. Now you choose two values l and r between 1 to n (both inclusive) where l has to be smaller than r ( l is left index r is right index). If l > r swap l and r. Now once you have chosen l and r you have to tell the expected value of number of unique elements in the array segment between l and r.
Basically koi bhi 2 indexes ke beech mei kitne unique values expected hai ye batao. To ye question maximum probability ka ban jayega ki 1 unique element ki prob sabse zyada hai ya 2 ki 3 ki etc.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Can you please explain the formula to be used here with some examples

@be10046.19 hey have a look at this code and dry run it,you will get it:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.