class Solution {
public int findMaxConsecutiveOnes(int[] nums) {
int maxCount = 0, count = 0;
int n = nums.length;
for(int i = 0; i < n; i++) {
if(nums[i] == 1) {
count++;
} else {
maxCount = Math.max(maxCount, count);
count = 0;
}
}
maxCount = Math.max(maxCount, count);
return maxCount;
}
}
class Solution {
public int findPoisonedDuration(int[] timeSeries, int duration) {
int n = timeSeries.length;
int endtime = timeSeries[0];
int total = 0;
for(int i = 0; i < n; i++) {
if(timeSeries[i] < endtime) {
total += duration - (endtime - timeSeries[i]);
} else {
total += duration;
}
endtime = timeSeries[i] + duration;
}
return total;
}
}