@grayhathacker I Tried to IMplement Your Logic , Maybe You can figure where i am going wrong
I Figured It , This Line Had To Be Changed ā¦
FROM
ans+=(bounds.second-bounds.first);
TO
ans+=((bounds.second-bounds.first)*((bounds.second-bounds.first)-1))/2LL;// C(N,2)
Your solution is even the better than the editorialistās.
in the first approach explained in the editorial how it will give the correct answer if all the elements of the vector h are sameā¦!!!..
@siddharth067 I didnāt understand why u did this ans+=((bounds.second-bounds.first)*((bounds.second-bounds.first)-1))/2LL;// C(N,2)