LeetCode 1481, Medium. Topics: Array, Hash Table, Greedy, Sorting, Counting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 18 parametrized pytest cases, and a playground notebook:
Problem
Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.
Examples
Constraints
- 1 <= arr.length <= 10^5
- 1 <= arr[i] <= 10^9
- 0 <= k <= arr.length
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026