728x90
반응형
SMALL
#include <string>
#include <vector>
#include <map>
using namespace std;
int solution(vector<int> array) {
if(array.size() ==1) return 1;
int answer = 0;
map<int, int> arr_map;
for(auto a : array)
arr_map[a]++;
for(auto itr = arr_map.begin(); itr != arr_map.end(); itr++) {
if(arr_map.size()==1) return itr->second;
if(answer < itr->second)
answer = itr->second;
else if(answer == itr->second)
answer = -1;
}
return answer;
}
728x90
반응형
LIST
'C++' 카테고리의 다른 글
[프로그래머스] 피자 나눠 먹기(1) (0) | 2025.09.02 |
---|---|
[프로그래머스] 짝수는 싫어요 (0) | 2025.09.01 |
[프로그래머스] 나머지 구하기, 중앙값 구하기 (0) | 2025.09.01 |
[프로그래머스] 배열 두 배 만들기 (0) | 2025.09.01 |
[프로그래머스] 분수의 덧셈 (0) | 2025.09.01 |
댓글