tell me the test case which it fails
Correct approach still not getting AC
Hi @chhabrapiyush480,
in ur last for loop, try using
for(long long int i=0; i<n; i++)
{
val=mp[i];
ans+=(val*(val-1))/2;
}
instead of using auto.
Hope dis helps.
here is d updated code.
@chhabrapiyush480,
I m sorry. Actually the mistake is not in for loop,u can use
for(auto g:mp)
{
val=g.second;
ans+=(val*(val-1))/2;
}
But was in pre[i]=((pre[i]+n)%n);
try using pre[i]=(((pre[i]%n)+n)%n);
i hv updated dis also in d above code.
Hope dis will help.