반응형
추천수를 가장 많이 받은 풀이와 내 풀이가 같은데, 거기서의 추천과 감탄 댓글들을 보면 괜히 내가 기분이 좋아지네..
// 사이즈는 5
// 6 5 4 1 0
// count++ 하면서, 뒤에서부터 갯수 세고 현재 원소의 값 얻고
// count가 원소보다 커지면 stop
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
sort(citations.begin(), citations.end(), greater<>());
int count = 0;
for(auto x : citations) {
if(count >= x)
break;
count++;
}
return count;
}
반응형
'[알고리즘 + 자료구조] > [프로그래머스]' 카테고리의 다른 글
프로그래머스 예상 대진표 (0) | 2023.08.09 |
---|---|
프로그래머스 영어 끝말잇기 (0) | 2023.08.08 |
프로그래머스 타겟 넘버 (0) | 2023.08.08 |
프로그래머스 카펫 (0) | 2023.08.07 |
프로그래머스 구명보트 (0) | 2023.08.07 |