Simple Fast java solution, 93%


  • 0
    S

    public class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
    if(timeSeries.length==0) return 0;
    int total =0;
    int begin = timeSeries[0];
    for(int i =1;i<timeSeries.length;i++){
    int gap = timeSeries[i]-begin;
    total += gap < duration ? gap : duration;
    begin = timeSeries[i];
    }
    return total + duration;
    }
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.