We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 692ae64 commit 15c9190Copy full SHA for 15c9190
src/1481-least-number-of-unique-integers-after-k-removals/index.js
@@ -0,0 +1,21 @@
1
+/**
2
+ * @param {number[]} arr
3
+ * @param {number} k
4
+ * @return {number}
5
+ */
6
+var findLeastNumOfUniqueInts = function (arr, k) {
7
+ const hash = {};
8
+ for (let i = 0; i < arr.length; i++) {
9
+ hash[arr[i]] = ~~hash[arr[i]] + 1;
10
+ }
11
+
12
+ const values = Object.values(hash).sort((x, y) => x - y);
13
+ let count = 0;
14
15
+ while (values[count] <= k) {
16
+ k -= values[count];
17
+ count++;
18
19
20
+ return values.length - count;
21
+};
0 commit comments