https://ide.geeksforgeeks.org/iAkKBIelFJ----what is the error in the code?
the output for sample input is not correct.
Subarrays with distinct elements problem
just a changes
ans += ((j - i ) * (j - i + 1)) / 2; Instead of ans += ((j-i+1)*(j-i+2))/2;
correct code :