Subarray with distinct element

Can you please tell me what is wrong with my code

hello @rahul.gupta03111999
ur formula needs bit modification
((j-i+1)*(j-i+2))/2
should be
((j-i)*(j-i+1))/2

because j is not a part of of answer hence j-i is the required lenght