Java solution | Beginner | One loop
Code\n\nclass Solution {\n    public int findPoisonedDuration(int[] timeSeries, int duration) {\n        int res = duration;\n\n        int prev = timeSeries[0]
# Code\n```\nclass Solution {\n    public int findPoisonedDuration(int[] timeSeries, int duration) {\n        int res = duration;\n\n        int prev = timeSeries[0];\n\n        for(int i = 1; i<timeSeries.length;i++){\n            if(timeSeries[i] <= timeSeries[i-1]+duration){\n                res+=timeSeries[i]-timeSeries[i-1];\n            } else {\n                res+=duration;\n            }\n        }\n\n        return res;\n    }\n}\n```
['Java']