@admin has 0 rating afaik. How much will you drop it now XD
Lol, Who will catch setterās solution? 
true⦠agree 100%
What the hell!!
I solved it using Merge Sort Tree. Hereās my solution : CodeChef: Practical coding for everyone
Fun Fact : In the init function, if you clear the whole arrays(size N), you will get TLE ![]()
May u suggest any test case
all setterās soln are matching with mine⦠setters are going to get plagiarized lolā¦
color grid also matches with minor changesā¦
Correction: You are going to be plagiarized. xD
cc the mail to me then XD
ā¦XD
It will depend upon the internal implementation of the unordered map. Maybe make a random test case generator and match output with Accepted solutions.
Whatās your logic precisely?
Actually @tarini_1407 havenāt made any attempts on any questions. It just posts to annoy @taran_1407 xP
For (a, b) to contribute to the answer, freq[a] >= b && freq[b] >= a. Thus, if we for some number(say num), we know the freq[num], candidates for b are 1, 2, 3, ⦠num. Which ones will actually be considered? The ones whose frequency is > num.
So, build merge sort tree on frequency array. Iterate through all the numbers, say freq of current number is curr. Check how many numbers have frequency > curr by querying the merge sort tree in range 1 to curr.
I hope it is clear!
Oof I did the exact opposite. My underlying array for the merge sort tree was the numbers 1 to 1e6 instead of the frequency values 
Thanks for explaining your way
I actually solved this in java. In Java, there is no such way where we can get the number of elements smaller than x. We have the function floor, which returns the element less than or equal to x. So, Order statistic tree is a must, at least for java users.