Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Last active April 27, 2020 07:29
Show Gist options
  • Save DongguemYoo/95318d0873c00a49c735098885ddb8aa to your computer and use it in GitHub Desktop.
Save DongguemYoo/95318d0873c00a49c735098885ddb8aa to your computer and use it in GitHub Desktop.
코딩테스트 연습 모의고사
//거의 인터넷 보고 푼 수준
//최대값 정렬하는데서 엄청 해맴
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> answers) {
vector<int> answer;
int player1[5] = {1,2,3,4,5};
int player2[8] = {2,1,2,3,2,4,2,5};
int player3[10] = {3,3,1,1,2,2,4,4,5,5};
int lenght = 3;
vector<int>count;
count.resize(lenght,0);
for(int i=0;i<answers.size();i++)
{
if(answers[i] == player1[i%5])
count[0]++;
if(answers[i] == player2[i%8])
count[1]++;
if(answers[i] == player3[i%10])
count[2]++;
}
///잘안됫던부분///잘안됫던부분///잘안됫던부분///잘안됫던부분///잘안됫던부분
int max = 0;
for(int i=0;i<count.size();i++)
{
if(count[i] >=max)
max = count[i];
}
for(int i=0;i<count.size();i++)
{
if(count[i] == max)
{
answer.push_back(i+1);
}
}
///잘안됫던부분///잘안됫던부분///잘안됫던부분///잘안됫던부분
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment