Programmers 77484
로또의 최고 순위와 최저 순위


CODE ⌨️

#include <string>
#include <vector>
#include <unordered_set>

using namespace std;

unordered_set<int> uset;

int sameCount = 0;
int zeroCount = 0;

int minRank, maxRank = 0;

int Rank[7] = { 6, 6, 5, 4, 3, 2, 1 };

vector<int> solution(vector<int> lottos, vector<int> win_nums)
{
    vector<int> answer;
    
    for (int i = 0; i < win_nums.size(); i++)
    {
        uset.insert(win_nums[i]);
    }
    
    for (int i = 0; i < lottos.size(); i++)
    {
        if (lottos[i] == 0)
        {
            zeroCount++;
        }
        else if (uset.count(lottos[i]) != 0)
        {
            sameCount++;
        }
    }
    
    minRank = Rank[sameCount];
    maxRank = Rank[sameCount + zeroCount];
    
    answer.push_back(maxRank);
    answer.push_back(minRank);
    
    return answer;
}



RESULT 💛



SIMPLE DISCUSSION ✏️

정렬 관련 문제였다. upper_boundlower_bound 관련하여 공부할 수 있었다.



SOURCE 💎

Programmers_Link 👈 Click here


*****
NOT A TALENT ❎ NOT GIVING UP ✅
CopyRight ⓒ 2022 DCherish All Rights Reserved.