Get Minimum Removal
Problem Overview
- Determine the minimum number of products to remove so the catalogue has at most k distinct categories.
- Input: n, an array catalogue of length n with category IDs, and k; Output: an integer for the minimum removals.
- Constraints: 1 ≤ n, k, catalogue[i] ≤ 1e5.
- Real-world context: cleaning an Amazon product catalogue; a common coding interview problem.
- Company: From Amazon interviews; classic interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
