프로그래머스코딩테스트연습풀이/C++

[프로그래머스/C++] 머쓱이보다 키 큰 사람

코코쵸마 2025. 2. 12. 15:40

문제

머쓱이는 학교에서 키 순으로 줄을 설 때 몇 번째로 서야 하는지 궁금해졌습니다. 머쓱이네 반 친구들의 키가 담긴 정수 배열 array와 머쓱이의 키 height가 매개변수로 주어질 때, 머쓱이보다 키 큰 사람 수를 return 하도록 solution 함수를 완성해보세요.

 

솔루션

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(vector<int> array, int height) {
    int answer = 0;
    answer = count_if(array.begin(), array.end(), [&](int x){return x > height;});
    return answer;
}

 

https://school.programmers.co.kr/learn/courses/30/lessons/120585

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr