DESTROY - Editorial

@archit910
answer of this test case 1 10 1 1 1 3 3 3 2 2 2 2 will be 5
5 pairs are:
(1,2)(1,2)(2,3)(2,3)(1,3)

@rednivrug15 there are 8 elements hence we need atleast 4 to destroy i guess

I want to know where i am going wrong in my code and which test case my code is failing.
please help!!!

Thanks for sharing this. I learned something new today :slight_smile:

1 Like

or u can find a pair in which u have the highest frequency and lowest,it is algebraically equivalent to taking pair of highest frequencies when u sum it all up.

how is complexity of editorialist code is (n*logn)…??

suppose there is two number in priority queue

a=1e9

b=1e9-1;

this will goes to approax 1e9 times??