코드카타-로또의 최고 순위와 최저 순위
#include <vector>
#include <unordered_set>
using namespace std;
int ToRank(int matchCount)
{
if (matchCount == 6) return 1;
else if (matchCount == 5) return 2;
else if (matchCount == 4) return 3;
else if (matchCount == 3) return 4;
else if (matchCount == 2) return 5;
else return 6;
}
vector<int> solution(vector<int> lottos, vector<int> win_nums)
{
// 1) 당첨 번호를 set으로 만들어 포함 여부를 빠르게 확인
unordered_set<int> winSet;
for (int n : win_nums)
{
winSet.insert(n);
}
int zeroCount = 0;
int matchCount = 0;
for (int x : lottos)
{
if (x == 0)
{
zeroCount++;
}
else
{
if (winSet.count(x) > 0) // 있으면 1, 없으면 0
{
matchCount++;
}
}
}
// 3) 최고/최저 매치 개수
int bestMatch = matchCount + zeroCount;
int worstMatch = matchCount;
// 4) 매치 개수 -> 등수 변환
int bestRank = ToRank(bestMatch);
int worstRank = ToRank(worstMatch);
return { bestRank, worstRank };
}
팀 프로젝트 KPT 회고
- Keep
- Problem
- 문제점 : 일을 제때 하지 않아서 막판에 몰아서 하였다.
- 해결 방안 : 자신의 집중력을 높여야겠다.
- Try
- Feel : 나의 실력이 향상되어가고 있지만 다른 조들에게서도 많이 배웠고, 아직 갈길이 멀다는 것도 느꼈습니다.