본문 바로가기
IT/알고리즘

46★] 프로그래머스 같은 숫자는 싫어

by 깻잎쌈 2020. 9. 15.
반응형

#include <vector>
#include<algorithm>
using namespace std;

vector<int> solution(vector<int> arr) 
{
     arr.erase(unique(arr.begin(), arr.end()), arr.end());
    return arr;
}

stackoverflow.com/questions/1041620/whats-the-most-efficient-way-to-erase-duplicates-and-sort-a-vector

 

What's the most efficient way to erase duplicates and sort a vector?

I need to take a C++ vector with potentially a lot of elements, erase duplicates, and sort it. I currently have the below code, but it doesn't work. vec.erase( std::unique(vec.begin(), vec....

stackoverflow.com

 

반응형

댓글