본문 바로가기

컴퓨터공학

[프로그래머스, C++] 없는 숫자 더하기

반응형
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>


using namespace std;

int solution(vector<int> numbers) {
    int answer = 0;
    int i=0;
    int num=0;
    sort(numbers.begin(),numbers.end());
    while(num<10){
        if(numbers[i]==num){
            i++;
        }
        else{
            answer+=num;
        }
        num++;
        
    }
    return answer;
}
반응형