Java Code beats 93% of Java submissions


  • 0
    S
    public class Solution {
        public int findPoisonedDuration(int[] t, int d) {
            if(t==null) return 0;
            if(t.length==1) return d;
            int i=0, err=0;
            while(i<t.length-1){
                if(t[i+1]<t[i]+d)
                    err = err + t[i+1] - t[i] - d;
                i++;
            }
            return t.length*d+err;
        }
    }
    

Log in to reply
 

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