Skip to content

Commit ca5cf4b

Browse files
committedFeb 16, 2025
Add solution #1207
1 parent 7da1a53 commit ca5cf4b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed
 

‎solutions/1207-unique-number-of-occurrences.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
* https://leetcode.com/problems/unique-number-of-occurrences/
44
* Difficulty: Easy
55
*
6-
* Given an array of integers arr, write a
7-
* function that returns true if and only
8-
* if the number of occurrences of each
9-
* value in the array is unique.
6+
* Given an array of integers arr, return true if the number of occurrences of each
7+
* value in the array is unique or false otherwise.
108
*/
119

1210
/**
13-
* @param {number[]} numbers
11+
* @param {number[]} arr
1412
* @return {boolean}
1513
*/
16-
var uniqueOccurrences = function(numbers) {
14+
var uniqueOccurrences = function(arr) {
1715
const map = new Map();
18-
numbers.forEach(n => map.set(n, map.has(n) ? map.get(n) + 1 : 1));
16+
arr.forEach(n => map.set(n, map.has(n) ? map.get(n) + 1 : 1));
1917
const occurrences = Array.from(map.values());
20-
return new Set(occurrences).size === occurrences.length
18+
return new Set(occurrences).size === occurrences.length;
2119
};

0 commit comments

Comments
 (0)
Please sign in to comment.