sir what is the reason for using this formula
(j-i)*(j-i+1)/2
what is the reason behind this??
Sir doubt in this question
hello @tejasddongare
let say we have length L subarray with all elements distinct.
then all subarray formed from this L length subarray will also contain distinct elements right?
so how many subarray possible from this L length subarray .
it will be LC2 + L -> L*(L-1)/2+ L
= > L*(L+1)/2
if L = j-i
then
=> (j-i) *(j-i+1)/2
sir i dont know permutation and combination can you show me different mathematical proof
ok , so from L lenght subarray
how many 1 lenght subarray possible -> L (right?)
how many 2 lenght subarray possible -> L-1
how many 3 lenght subarray possible-> L-2
how many 4 lenght subarray possible-> L-3
…
how many L lenght subarray possible-> 1
now compute its sum-> L+ L-1 + L-2 + L-3 + L-4 …+ 2 + 1
it is simple summation -> L*(L+1)/2
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.