Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
293 B
16
Indexable
Never
public class Solution {
    public int solve(int[] A) {
        int chunks = 0;
        int max = -1;
        for(int i = 0 ; i < A.length; i++){
            max = Math.max(A[i], max);
            if(i == max){
                chunks++;
            }
        }
        return chunks; 
    }
}