#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> lottos, vector<int> win_nums) {
vector<int> answer;
int x= 0, same = 0;
sort(lottos.begin(), lottos.end());
sort(win_nums.begin(),win_nums.end());
int l_point = 0, w_point = 0;
while(l_point < 6 && w_point < 6){
//0이 있는 경우
if(lottos[l_point] == 0) {
x++;
l_point++;
continue;
}
//같은 경우
if(lottos[l_point] == win_nums[w_point]) {
same++;
l_point++; w_point++;
continue;
}
//다른 경우 1 - lottos가 더 큰 경우
else if(lottos[l_point] > win_nums[w_point]) {
w_point++;
continue;
}
//다른 경우 2
else {
l_point++;
continue;
}
} //while 종료
//최고 순위 삽입
int high = same + x;
if(high <= 1) answer.push_back(6);
else answer.push_back(7-high);
//최저 순위 삽입
if(same <= 1) answer.push_back(6);
else answer.push_back(7-same);
return answer;
}
'CodingTest Practice > Programmers' 카테고리의 다른 글
프로그래머스 : 없는 숫자 더하기 (C++, Lv.1) (0) | 2021.12.30 |
---|---|
프로그래머스 : 신규 아이디 추천 (C++, Lv.1) (0) | 2021.12.30 |
프로그래머스 : 문자열 다루기 기본 (C++) (0) | 2021.12.30 |
프로그래머스 : 모의고사 (C++, Lv.1) (0) | 2021.12.30 |
프로그래머스 : 기능개발 (C++) (0) | 2021.10.20 |