-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
혹시 강사님 이 풀이는 효율적이지 못할까요?
22.03.27 23:40 작성 조회수 168
0
function solution(s1,s2) {
let answer = 'YES';
console.log(s1,s2)
let map1 = new Map();
for(let s of s1) {
if(map1.has(s)) map1.set(s, map1.get(s)+1);
else map1.set(s,1);
}
let map2 = new Map();
for(let s of s2) {
if(map2.has(s)) map2.set(s, map2.get(s)+1);
else map2.set(s,1);
}
for(let s of s1) {
if(map1.get(s) !== map2.get(s)) answer = 'NO'; break;
}
return answer;
}
let str1 = 'abaCC';
let str2 = 'Caaab';
console.log(solution(str1,str2))
답변을 작성해보세요.
0
답변 1