function solution(table, languages, preference) {
const person={}
for(let i=0;i<languages.length;i++){
const lang=languages[i];
for(const tab of table){
const tabs=tab.split(" ");
if(person[tabs[0]]===undefined)
person[tabs[0]]=0;
for(let j=0;j<tabs.length;j++){
if(tabs[j]===lang){
person[tabs[0]]+=(tabs.length-j)*preference[i];
}
}
}
}
const values=Object.values(person)
const max= Math.max(...values)
const maxs=Object.entries(person)
.filter(val=>val[1]===max)
.map(val=>val[0]);
maxs.sort()
return maxs[0];
}
추석이라 한문제만 풀기로 했는데
생각보다 어려웠다.