본문 바로가기

코딩 테스트/프로그래머스

[Level 1, C++] 서울에서 김서방 찾기

728x90
반응형

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

string solution(vector<string> seoul) {
    string answer = "";
    for(string & s : seoul) {
        if(s == "Kim") {
            answer = "김서방은 " + to_string(&s - &*seoul.begin()) + "에 있다"; 
            break;
        }
    }
    return answer;
}
728x90
반응형