java.lang.Object
g1401_1500.s1481_least_number_of_unique_integers_after_k_removals.Solution

public class Solution extends Object
1481 - Least Number of Unique Integers after K Removals.<p>Medium</p> <p>Given an array of integers <code>arr</code> and an integer <code>k</code>. Find the <em>least number of unique integers</em> after removing <strong>exactly</strong> <code>k</code> elements**.**</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> arr = [5,5,4], k = 1</p> <p><strong>Output:</strong> 1</p> <p><strong>Explanation:</strong> Remove the single 4, only 5 is left.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> arr = [4,3,1,1,3,3,2], k = 3</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= arr.length <= 10^5</code></li> <li><code>1 <= arr[i] <= 10^9</code></li> <li><code>0 <= k <= arr.length</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • findLeastNumOfUniqueInts

      public int findLeastNumOfUniqueInts(int[] arr, int k)