NORTHROP GRUMMAN | Off-Campus OA (2022) | Reduce Array Size to The Half

Question · Posted Jun 2026

Problem Statement You are given an integer array arr. In one operation, you can choose a distinct integer and remove all of its occurrences from the array. Return the minimum number of distinct integers that need to be removed so that the size of the remaining array becomes at most half of its original size. Example Input: arr = [3,3,3,3,5,5,5,2,2,7] Output: 2 Explanation: Frequency of elements: 3 → 4 5 → 3 2 → 2 7 → 1 Remove 3 ...

The full answer & interview discussion are available to premium members.

Log in Create a free account