본문 바로가기
Codility

Codility MaxNonoverlappingSegments C++

by paysmile 2021. 7. 15.

https://app.codility.com/programmers/lessons/1-iteration

 

Codility

Your browser is not supported You should use a supported browser. Read more

app.codility.com

 

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;
}