import java.util.*;
class Solution {
private int left;
private int right = left;
private int tied;
private int tiedCount;
public int solution(int K, int[] A) {
while (left < A.length && right < A.length) {
tied += A[right];
if (tied >= K) {
left = right + 1;
right = left;
tied = 0;
tiedCount++;
} else {
right++;
}
}
return tiedCount;
}
}
Codility - TieRopes
2019년 8월 12일 월요일
·