seunghyun Note
[프로그래머스] 배열의 원소 삭제하기 with JS 본문
728x90
반응형
링크 : https://school.programmers.co.kr/learn/courses/30/lessons/181844?language=javascript
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
문제 풀이
차집합을 이용해서 문제를 해결하자
How to get the difference between two arrays in JavaScript?
Is there a way to return the difference between two arrays in JavaScript? For example: var a1 = ['a', 'b']; var a2 = ['a', 'b', 'c', 'd']; // need ["c", "d"]
stackoverflow.com
function solution(arr, delete_list) {
return arr.filter((x) => !delete_list.includes(x));
}
728x90
반응형
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
[백준] 2164 카드2 with JS (0) | 2024.01.24 |
---|---|
[백준] 18258번 : 큐 2 with JS (0) | 2024.01.23 |
[백준] 12789번 : 도키도키 간식드리미(스택 공부 부수기) with JS (0) | 2024.01.20 |
[백준] 4949번 : 균형잡힌 세상(스택 공부 부수기) with JS (0) | 2024.01.18 |
[백준] 9012번 : 괄호 (스택 공부 부수기) with JS (0) | 2024.01.18 |