https://app.codility.com/programmers/lessons/1-iteration
int solution(vector<int> &A, vector<int> &B) {
if(A.size() <=1) return A.size();
int cur = B[0];
int answer = 1;
for(int i=1; i<A.size(); i++){
if(A[i] > cur){
cur = B[i];
answer +=1;
}
}
return answer;
}
'Codility' 카테고리의 다른 글
[Codility] Caterpillar Method : AbsDistinct (0) | 2021.07.16 |
---|---|
[Codility] Caterpillar method : CountTriangles (0) | 2021.07.16 |
[Codility] Lesson15 - Caterpillar method: MinAbsSumOfTwo (0) | 2021.07.16 |
Codility TieRopes C++ (0) | 2021.07.15 |