[C++] most simple logic
\nclass Solution {\npublic:\n    int findPoisonedDuration(vector<int>& a, int d) {\n        int n = a.size();\n        if(n==0)\n            return 0;\n        
```\nclass Solution {\npublic:\n    int findPoisonedDuration(vector<int>& a, int d) {\n        int n = a.size();\n        if(n==0)\n            return 0;\n        long long int ans = 0;\n        int time = 0;\n        for(int i=1;i<n;i++)\n        {\n            if(a[i]-a[i-1]>=d)\n                ans+=d;\n            else ans += a[i]-a[i-1];\n        }\n        ans += d;\n        return ans;\n    }\n};\n```
[]