[
counter
sort
greedy
hash table
]
BinarySearch 0905 Remove Half of the List
Problem statement
https://binarysearch.com/problems/Remove-Half-of-the-List/
Solution
Equal to 1338. Reduce Array Size to The Half.
Complexity
It is O(n log n)
for time and O(n)
for space.
Code
class Solution:
def solve(self, A):
return [2*i >= len(A) for i in accumulate(sorted(Counter(A).values())[::-1])].index(True) + 1