728x90
문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/120903
나의 풀이
function solution(s1, s2) {
let countarray = []
for(i=0;i<s1.length;i++){
if (s2.includes(s1[i])){
countarray.push(s1[i])
}
}
for(j=0;j<s2.length;j++){
if (s1.includes(s2[j])&&!countarray.includes(s2[j])){
countarray.push(s1[j])
}
}
return countarray.length
}
다른 사람의 풀이
function solution(s1, s2) {
const intersection = s1.filter((x) => s2.includes(x));
return intersection.length;
}
소감
점점 문제 난이도가 올라가면서 투자해야 하는 시간이 늘어난다!
3시간 동안 공 던지기 문제를 풀었지만 해결하지 못하여 쉬운 문제를 먼저 풀었다....
'verdantjuly > 코딩테스트' 카테고리의 다른 글
프로그래머스 코딩테스트 입문 : 자릿수 더하기 (javascript, 20230617) (0) | 2023.06.17 |
---|---|
프로그래머스 코딩테스트 입문 : 머쓱이보다 키 큰 사람 (javascript, 20230616) (0) | 2023.06.16 |
프로그래머스 코딩테스트 입문 : 편지 (javascript, 20230614) (0) | 2023.06.14 |
프로그래머스 코딩테스트 입문 : 2차원으로 만들기 (javascript, 20230613) (0) | 2023.06.13 |
프로그래머스 코딩테스트 기초 : 배열의 원소만큼 추가하기 (0) | 2023.06.12 |