DESTROY - Editorial

Oh yes! Couldn’t think of that…Thanks

Excellent. How did you come up with that? Why does it work?

I used a similar approach but not O(n). I think it is correct because there will exist a number different than itself to pair it with if occurrence of a number is less than half of the size of the array. On the other hand if a number repeats more than n/2 times you cannot find a number to pair it with after (size - maxcount) times. Hope you understood why it is right.
I used a different approch to calculate count and CodeChef: Practical coding for everyone is the link to my solution.

excellent :slight_smile:

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

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

1 Like

nice approach