-
Migratory Birds해커랭크(HackerRank) 2018. 8. 19. 17:36반응형
1. 문제
2. 알고리즘
키워드 - 구현
3. 코드
1234567891011121314151617181920212223242526272829303132333435#include <bits/stdc++.h>using namespace std;int migratoryBirds(int n, vector <int> ar) {// Complete this functionint brr[6] = {0,};const int size = ar.size();for(int i = 0; i < size; i ++) {brr[ar[i]]++;}int result = 1; int max = 0;for(int i = 1; i <= 5; i ++) {if(max < brr[i]) {max = brr[i];result = i;}}return result;}int main() {int n;cin >> n;vector<int> ar(n);for(int ar_i = 0; ar_i < n; ar_i++){cin >> ar[ar_i];}int result = migratoryBirds(n, ar);cout << result << endl;return 0;}cs 반응형'해커랭크(HackerRank)' 카테고리의 다른 글
Birthday Chocolate (0) 2018.08.19 Divisible Sum Pairs (0) 2018.08.19 Bon Appétit (0) 2018.08.19 Sock Merchant (0) 2018.08.19 Cats and a Mouse (0) 2018.08.19