Java 7 lines O(n) solution
For each begin followed by t\nIf t is within previous duration [begin, begin + duration] then increase total by t - begin\nIf t in out of previous duration [beg
For each ```begin``` followed by ```t```\nIf ```t``` is within previous duration ```[begin, begin + duration]``` then increase total by ```t - begin```\nIf ```t``` in out of previous duration ```[begin, begin + duration]``` then increase total by ```duration```\nIn both cases update ```begin``` to the new begin time ```t```\n\n```\n    public int findPoisonedDuration(int[] timeSeries, int duration) {\n        if (timeSeries.length == 0) return 0;\n        int begin = timeSeries[0], total = 0;\n        for (int t : timeSeries) {\n            total = total + (t < begin + duration ? t - begin : duration);\n            begin = t;\n        }   \n        return total + duration;\n    } \n```
[]