#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

vector<int> solution(vector<int> answers) {
    vector<int> answer;
    vector<int> a={1,2,3,4,5};
    vector<int> b={2, 1, 2, 3, 2, 4, 2, 5};
    vector<int> c={3, 3, 1, 1, 2, 2, 4, 4, 5, 5};
    vector<int> count_vec = {0, 0, 0};
    for(int i=0; i<answers.size();i++){
        if(answers[i]==a[i%a.size()]){
            count_vec[0]++;
        }
        if(answers[i]==b[i%b.size()]){
            count_vec[1]++;
        }
        if(answers[i]==c[i%c.size()]){
            count_vec[2]++;
        }
    }
    //cout<<count_vec[0]<<", "<<count_vec[1]<<", "<<count_vec[2]<<endl;
    //cout<<max_element(count_vec.begin(), count_vec.end()) - count_vec.begin()<<endl;
    int max_v = *max_element(count_vec.begin(), count_vec.end());
    for(int i=0; i< count_vec.size();i++){
        if(count_vec[i] == max_v){
            answer.push_back(i+1);    
        }
        
    }
    return answer;
}

 

'알고리즘 > 풀이' 카테고리의 다른 글

[프로그래머스/C++] 숫자 야구  (0) 2019.12.30
[프로그래머스/C++] 가운데 글자 가져오기  (0) 2019.11.30
[프로그래머스/Python] 탑  (0) 2019.11.15
[Programmers] 프린터  (0) 2019.11.11
[Programmers] Python 위장  (0) 2019.11.11

+ Recent posts