728x90
반응형
문제 : 해커랭크 - Breaking the Recods
난이도: Easy
언어 : C++
// Complete the breakingRecords function below.
vector<int> breakingRecords(vector<int> scores) {
int bestScoreCnt = 0;
int worstScoreCnt = 0;
int maxScore = scores.at(0);
int minScore = scores.at(0);
vector<int> ret ;
for(auto iter = scores.begin(); iter!=scores.end();iter++)
{
if(*iter>maxScore)
{
bestScoreCnt++;
maxScore= *iter;
}
if(*iter<minScore)
{
worstScoreCnt++;
minScore = *iter;
}
}
ret.push_back(bestScoreCnt);
ret.push_back(worstScoreCnt);
return ret;
}
728x90
반응형
'개발 > 코딩' 카테고리의 다른 글
해커랭크(HackerRank) - Day of the Programmer / C++ (0) | 2020.02.05 |
---|---|
해커랭크(HackerRank) - Migratory Birds / C++ (0) | 2020.02.04 |
해커랭크(HackerRank) - Mini-Max Sum / C++ (0) | 2020.02.04 |
해커랭크(HackerRank) - Divisible Sum Pairs / C++ (0) | 2020.02.03 |
해커랭크(HackerRank) - Birthday Chocolate / C++ (0) | 2020.02.03 |
댓글