package leetcode;

/**
 * https://leetcode.com/problems/teemo-attacking/
 */
public class Problem495 {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem495 prob = new Problem495();
        System.out.println(prob.findPoisonedDuration(new int[]{1, 4}, 2)); // 4
        System.out.println(prob.findPoisonedDuration(new int[]{1, 2}, 2)); // 3
    }
}

@@ -178,16 +178,65 @@
     
-// TODO%0A
+int total = 0;%0A        if (timeSeries.length == 0) %7B%0A    
     
@@ -250,266 +250,336 @@
 urn 
-0
+total
 ;%0A    
+ 
+   
 %7D
-%0A
 %0A    
-public static void main(String%5B%5D args) %7B%0A        Problem495 prob = new Problem495();%0A        System.out.println(prob.findPoisonedDuration(new int%5B%5D%7B1, 4%7D, 2)); // 4%0A        System.out.println(prob.findPoisonedDuration(new int%5B%5D%7B1, 2%7D, 2)); // 3
+    for (int i = 0; i %3C timeSeries.length - 1; i++) %7B%0A            if (timeSeries%5Bi%5D + duration %3C= timeSeries%5Bi + 1%5D) %7B%0A                total += duration;%0A            %7D else %7B%0A                total += timeSeries%5Bi + 1%5D - timeSeries%5Bi%5D;%0A            %7D%0A        %7D%0A        total += duration;%0A        return total;
 %0A   

Solve problem 495