https://programmers.co.kr/learn/courses/30/lessons/77484?language=cpp
#include <algorithm>
#include <vector>
#include <iostream>
vector<int> target;
int i = 0;
auto res = find(target.begind(), target.end(), i);
if (res != target.end()) cout << "find" << endl;
// 복사
dest.assign(source.begin(), source.end());
// 삭제
dest.erase(idx);
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int get_rank(int correct) {
int rank;
if (correct >= 2) {
rank = 7 - correct;
}
else {
rank = 6;
}
return rank;
}
void print_vector(vector<int> target) {
for (auto i: target) {
cout << i << ' ';
}
cout << endl;
}
vector<int> solution(vector<int> lottos, vector<int> win_nums) {
vector<int> answer;
// worst: lottos와 win_nums를 비교
// best: worst + 0의 개수
int zero_cnt = 0, cnt = 0;
for (auto& i: lottos) {
// count zero
if (i == 0) {
zero_cnt++;
continue;
}
// check
auto res = find(win_nums.begin(), win_nums.end(), i);
if (res != win_nums.end()) {
cnt++;
}
}
int best = get_rank(cnt + zero_cnt), worst = get_rank(cnt);
answer.push_back(best);
answer.push_back(worst);
return answer;
}