class Solution { public int findPoisonedDuration(int[] timeSeries, int duration) { int ans=0; for (int i = 0; i < timeSeries.length; i++) { if(i<timeSeries.length-1){ ans+= Math.min(timeSeries[i + 1] - timeSeries[i], duration); } else{ ans+=duration; } } return ans; } }