Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

완주하지 못한 선수 풀이 #1

Open
ssionii opened this issue Oct 8, 2019 · 0 comments
Open

완주하지 못한 선수 풀이 #1

ssionii opened this issue Oct 8, 2019 · 0 comments

Comments

@ssionii
Copy link
Member

ssionii commented Oct 8, 2019

다른 사람의 풀이 중에 좋은 풀이를 가져왔습니다.

#include <string> 
#include <vector> 
#include <algorithm> 

using namespace std;  

string solution(vector<string> participant, vector<string> completion) {  

     string answer = "";     
     sort(participant.begin(), participant.end());     
     sort(completion.begin(), completion.end());     

     for(int i=0;i<completion.size();i++) {        
          if(participant[i] != completion[i])             
               return participant[i];     
     }     
     
     return participant[participant.size() - 1];     //return answer; 
}

해시라는 자료구조를 이용해서 풀라고 해서 해시로 풀었지만,
상관없이 푼다면 이렇게 풀어도 좋은 문제네요! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant