상세 컨텐츠

본문 제목

[HackerRank] Hash Tables: Ransom Note (C++)

PROGRAMMING/Algorithm

by koharin 2021. 1. 14. 20:31

본문

728x90
반응형
void checkMagazine(vector<string> magazine, vector<string> note) {
    //map<string, string> m;
    sort(magazine.begin(), magazine.end());
    sort(note.begin(), note.end());
    if(includes(magazine.begin(), magazine.end(), note.begin(), note.end())){
        cout << "Yes" << endl;
    }
    else{ cout << "No" << endl; }
}
  • includes를 사용해서 note가 magazine의 subset이면 Yes를, 아니면 No를 출력한다.
728x90
반응형

관련글 더보기