easy understand solution(java)


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

Log in to reply
 

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