문제
정수 배열 arr과 delete_list가 있습니다. arr의 원소 중 delete_list의 원소를 모두 삭제하고 남은 원소들은 기존의 arr에 있던 순서를 유지한 배열을 return 하는 solution 함수를 작성해 주세요.
솔루션
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> arr, vector<int> delete_list) {
vector<int> answer;
for(auto n:delete_list){
arr.erase(remove(arr.begin(), arr.end(),n),arr.end());
}
return arr;
}
https://school.programmers.co.kr/learn/courses/30/lessons/181844
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
'프로그래머스코딩테스트연습풀이 > C++' 카테고리의 다른 글
[프로그래머스/C++] 부분 문자열 (0) | 2025.02.20 |
---|---|
[프로그래머스/C++] 공백으로 구분하기 1 (0) | 2025.02.20 |
[프로그래머스/C++] 덧셈식 출력하기 (0) | 2025.02.20 |
[프로그래머스/C++] 9로 나눈 나머지 (0) | 2025.02.20 |
[프로그래머스/C++] 조건에 맞게 수열 변환하기 3 (0) | 2025.02.20 |