Skip to content

Instantly share code, notes, and snippets.

@niklasjang
Created August 24, 2020 12:17
Show Gist options
  • Save niklasjang/5654cdc8206db177144303c3444f7866 to your computer and use it in GitHub Desktop.
Save niklasjang/5654cdc8206db177144303c3444f7866 to your computer and use it in GitHub Desktop.
[PS][KAKAO BLIND RECRUITMENT][2020][가사 검색]
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;
bool check(string a, string b) {
if (a.size() != b.size()) return false;
int size = a.size();
for (int i = 0; i < size; i++) {
if (b[i] == '?') continue;
if (a[i] != b[i]) return false;
}
return true;
}
vector<int> solution(vector<string> words, vector<string> queries) {
vector<int> answer;
int qsize = queries.size();
int wsize = words.size();
for (int i = 0; i < qsize; i++) {
answer.push_back(0);
for (int j = 0; j < wsize; j++) {
if (check(words[j], queries[i])) {
answer[i]++;
}
}
}
return answer;
}
int main() {
int n = 0;
vector<string> word, query;
vector<int> ans;
for (int i = 0; i < 6; i++) {
string s;
cin >> s;
word.push_back(s);
}
for (int i = 0; i < 5; i++) {
string s;
cin >> s;
query.push_back(s);
}
ans = solution(word, query);
int size = ans.size();
for (int i = 0; i < size; i++) {
cout << ans[i] << " ";
}
cout << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment