내가 보는 프로그래머스 벡터 중복 요소 제거 문제
문제 설명 : 숫자를 담은 벡터를 input 값 으로 받는다. 벡터에서 연속된 숫자 부분은 한번만 저장되도록 바꾼다. ex) [1,1,1,3,3,0,1,1] >> [1,3,0,1] 간단하게 짧은 line으로 푼 풀이가 있어서 작성한다. #include #include #include using namespace std; vector solution(vector arr) { arr.erase(unique(arr.begin(), arr.end()),arr.end()); vector answer = arr; return answer; } C++ vector의 erase 멤버 함수 iterator erase (const_iterator position); iterator erase (const_iterator ..