-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path64065.js
33 lines (28 loc) · 803 Bytes
/
64065.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function solution(s) {
var answer = [];
var temp = s.split('{').join('.').split('}').join('.').split('.');
var object={};
for(var i=0; i<temp.length; i++){
if(temp[i].length==0)
continue;
var temp2 = temp[i].split(',');
for(var j=0; j<temp2.length; j++){
if(temp2[j].length==0)
continue;
if(object[temp2[j]])
object[temp2[j]]++;
else
object[temp2[j]]=1;
}
}
var sortable=[];
for(var item in object){
sortable.push([item, object[item]]);
}
sortable.sort(function(a,b){
return b[1]-a[1];
})
for(var i=0; i<sortable.length; i++)
answer.push(parseInt(sortable[i][0]));
return answer;
}