Java solution for Teemo


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

Log in to reply
 

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