Subarrays with distinct elements problem

https://ide.geeksforgeeks.org/iAkKBIelFJ----what is the error in the code?
the output for sample input is not correct.

Hey @AbhishekAhlawat1102

just a changes
ans += ((j - i ) * (j - i + 1)) / 2; Instead of ans += ((j-i+1)*(j-i+2))/2;
correct code :