Grokking the Engineering Manager Coding Interview
Ask Author
Back to course home

0% completed

Least Number of Unique Integers after K Removals (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given an array of integers arr and an integer k, return the least number of unique integers remaining after removing exactly k elements from the array.

Examples

Example 1

  • Input: arr = [5, 5, 4, 3, 2, 3, 2, 3, 3, 2], k = 6
  • Expected Output: 1
  • Justification: After removing 4, all 5, and three instances of 2, the updated array will be [3, 3, 3, 3]. It will have only 1 unique element.

Example 2

  • Input: arr = [7, 7, 7, 8, 8, 9], k = 2
  • Expected Output: 2

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible