๋ฌธ์
์ฝ๋
#include <vector>
#include <map>
using namespace std;
int solution(vector<int> nums)
{
map<int,int>m;
int answer = 0;
for(int i=0; i<nums.size(); i++){
m[nums[i]]++;
}
answer=m.size();
if(answer>nums.size()/2) answer=nums.size()/2;
return answer;
}
'Algorithm ๐ง๐ปโ๐ป > ํ๋ก๊ทธ๋๋จธ์ค(Programmers)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ๋ฐฉ๋ฌธ ๊ธธ์ด( Level 2) (0) | 2021.11.08 |
---|---|
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์๋ ์ซ์ ๋ํ๊ธฐ( Level 1) (0) | 2021.11.07 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํธ๋ํฐ ๋ฒํธ ๊ฐ๋ฆฌ๊ธฐ( Level 1) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํํ( Level 2) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํ๊ฒ ๋๋ฒ( Level 2) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์นด์นด์ค ํ๋ ์ฆ ์ปฌ๋ฌ๋ง๋ถ( Level 2, 2017 ์นด์นด์ค ์ฝ๋ ์์ ) (0) | 2021.10.23 |
๋๊ธ