Skip to content
Veltoryx Technologies
ProProblem 14● MediumLeetCode #1338 ↗2 min readUpdated 30 October 2026

Reduce Array Size to The Half

Remove at least half the numbers using as few distinct values as possible, by removing the most frequent values first.

01The problem

Choose a set of values and remove every occurrence of them from arr. Return the smallest number of values you need so that at least half the array is removed.

InputOutputWhy
[3,3,3,3,5,5,5,2,2,7]2remove 3 and 5: 7 of 10 gone
[7, 7, 7, 7]1remove 7

Loading the rest of the lesson…