문제
정수가 담긴 배열 array와 정수 n이 매개변수로 주어질 때, array에 n이 몇 개 있는 지를 return 하도록 solution 함수를 완성해보세요.
솔루션
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> array, int n) {
return count(array.begin(), array.end(), n);
}
https://school.programmers.co.kr/learn/courses/30/lessons/120583
'프로그래머스코딩테스트연습풀이 > C++' 카테고리의 다른 글
[프로그래머스/C++] 중앙값 구하기 (0) | 2025.02.13 |
---|---|
[프로그래머스/C++] 배열 두배 만들기 (0) | 2025.02.13 |
[프로그래머스/C++] 홀짝에 따라 다른 값 반환하기 (0) | 2025.02.13 |
[프로그래머스/C++] 두 수의 나눗셈 (0) | 2025.02.13 |
[프로그래머스/C++] 홀짝 구분하기 (0) | 2025.02.13 |