SUBARRAYS WITH DISTINCT ELEMENTS


What is wrong with this code? Sample inputs are giving correct output, but all test cases are not getting passed.

@AbhilashaBansal
You forgot to use modulo 10^9+7
Also use long long instead of int to avoid overflow error

All test cases are still not getting passed. [https://ide.codingblocks.com/s/229949]

@AbhilashaBansal
I’ve modified your code here https://ide.codingblocks.com/s/230418
2 mistakes
Firstly you need to use modulo everytime you perform addition to sum and use long long for variables which are being used for multiplication of large number (i, j in your case )
Second your loop condition was incorrect going till just n-2

Thanks for your help!

1 Like