File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -10,27 +10,27 @@ var minDeletions = function(s) {
10
10
// hash frequency
11
11
let i = 0 ;
12
12
const charHash = new Map ( ) ;
13
- while ( i < s . length ) {
13
+ while ( i < s . length ) {
14
14
const frequency = charHash . get ( s [ i ] ) || 0 ;
15
- charHash . set ( s [ i ] , frequency + 1 ) ;
15
+ charHash . set ( s [ i ] , frequency + 1 ) ;
16
16
i ++ ;
17
17
}
18
18
const frequencyHash = new Map ( ) ;
19
- for ( const [ key , val ] of charHash ) {
19
+ for ( const [ key , val ] of charHash ) {
20
20
const frequency = frequencyHash . get ( val ) || 0 ;
21
- frequencyHash . set ( val , frequency + 1 ) ;
21
+ frequencyHash . set ( val , frequency + 1 ) ;
22
22
}
23
23
24
24
let min = 0 ;
25
- for ( const [ key , val ] of frequencyHash ) {
25
+ for ( const [ key , val ] of frequencyHash ) {
26
26
let frequency = key ;
27
27
let frequencyOfFrequency = val ;
28
28
while ( frequencyOfFrequency > 1 ) {
29
29
while ( frequencyHash . has ( frequency ) ) {
30
30
frequency -= 1 ;
31
31
min += 1 ;
32
32
}
33
- if ( frequency > 0 ) frequencyHash . set ( frequency , 1 ) ;
33
+ if ( frequency > 0 ) frequencyHash . set ( frequency , 1 ) ;
34
34
frequency = key ;
35
35
frequencyOfFrequency -= 1 ;
36
36
}
You can’t perform that action at this time.
0 commit comments