웅재의 코딩세상

[프로그래머스] 서울에서 김서방 찾기 본문

코딩테스트/프로그래머스 - LV 1

[프로그래머스] 서울에서 김서방 찾기

웅드 2024. 2. 9. 17:23

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

string solution(vector<string> seoul) {
    string answer = "";
    for(int i=0; i<seoul.size(); i++){
        if(seoul[i]=="Kim"){
            answer = "김서방은 " + to_string(i) + "에 있다";
        }
    }
    return answer;
}
반응형