Beginner Friendly || Easy To Understand || C++ Code
Time Complexity : O(N)\n Space Complexity : O(N)*\n\n\nint findPoisonedDuration(vector<int>& time, int duration) {\n        \n        int n = time.size();\n    
* ***Time Complexity : O(N)***\n* ***Space Complexity : O(N)***\n\n```\nint findPoisonedDuration(vector<int>& time, int duration) {\n        \n        int n = time.size();\n        \n        vector<pair<int, int>> res;\n        \n        for(int i = 0; i < n; i++)\n        {\n            int x = time[i];\n            int y = time[i] + duration - 1;\n            \n            res.push_back({x, y});\n        }\n        \n        \n        int ans = 0;\n        \n        ans += res[0].second - res[0].first + 1;\n        \n        for(int i = 1; i < n; i++)\n        {\n            if(res[i].first <= res[i-1].second)\n            {\n                int temp = (res[i].second - res[i].first) - (res[i-1].second - res[i].first);\n                ans += temp;\n            }\n            \n            else\n            {\n                ans += res[i].second - res[i].first + 1;\n            }\n        }\n        \n        return ans;\n    }\n```
['Greedy']