250x250
반응형
Notice
Recent Posts
Recent Comments
Link
목록Easy (1)
N

연속적으로 같은 숫자가 오는지 확인만 해주면 간단하게 풀 수 있는 문제..! 처음에는 pre변수를 arr[0]에 있는 숫자로 초기화 해준다. 이 후 for문에서 arr[1]부터 끝까지 pre 변수와 비교해가면서 확인. 연속적이지 않으면 pre변수를 바꿔주고 answer 벡터에 넣어주면 끄으으읕..! #include #include #include using namespace std; vector solution(vector arr) { vector answer; int pre = arr[0]; answer.push_back(pre); for(int i = 1; i < arr.size(); i++) { if(pre != arr[i]) { pre = arr[i]; answer.push_back(pre); }..
프로그래머스 알고리즘/1단계
2020. 4. 23. 13:17