O(n) Java Solution using same idea of merge intervals
The same idea as https://leetcode.com/problems/merge-intervals/\nAlgorithm:\n1. Use two variable to record current start and end point.\n2. If the start of new 
The same idea as https://leetcode.com/problems/merge-intervals/\nAlgorithm:\n1. Use two variable to record current start and end point.\n2. If the start of new interval is greater than current end, meaning NO overlapping, we can sum the current interval length to result and then update start and end.\n3. Otherwise just update the current end;\n\n```\npublic class Solution {\n    public int findPosisonedDuration(int[] timeSeries, int duration) {\n        if (timeSeries == null || timeSeries.length == 0 || duration == 0) return 0;\n        \n        int result = 0, start = timeSeries[0], end = timeSeries[0] + duration;\n        for (int i = 1; i < timeSeries.length; i++) {\n            if (timeSeries[i] > end) {\n                result += end - start;\n                start = timeSeries[i];\n            }\n            end = timeSeries[i] + duration;\n        }\n        result += end - start;\n        \n        return result;\n    }\n}\n```
[]