Short O(n) C++ solution
```\nlass Solution {\npublic:\n    int findPosisonedDuration(vector& ts, int duration) {\n        int tp = 0, pe = 0;\n        for(int i=0; i<ts.size(); ++i){\n
```\nlass Solution {\npublic:\n    int findPosisonedDuration(vector<int>& ts, int duration) {\n        int tp = 0, pe = 0;\n        for(int i=0; i<ts.size(); ++i){\n            tp += duration - (ts[i] < pe) *(pe - ts[i]);\n            pe = ts[i] + duration;\n        }\n        return tp;\n    }\n};
[]