Clear Java Solution


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

Log in to reply
 

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