File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 3
3
* https://leetcode.com/problems/unique-number-of-occurrences/
4
4
* Difficulty: Easy
5
5
*
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.
10
8
*/
11
9
12
10
/**
13
- * @param {number[] } numbers
11
+ * @param {number[] } arr
14
12
* @return {boolean }
15
13
*/
16
- var uniqueOccurrences = function ( numbers ) {
14
+ var uniqueOccurrences = function ( arr ) {
17
15
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 ) ) ;
19
17
const occurrences = Array . from ( map . values ( ) ) ;
20
- return new Set ( occurrences ) . size === occurrences . length
18
+ return new Set ( occurrences ) . size === occurrences . length ;
21
19
} ;
You can’t perform that action at this time.
0 commit comments