3-liner very short C++ O(N) time O(1) space, only count increments (with explanation)
This is actually a very easy problem covered by a gaming story.\n\nKey Observation: The extra poison duration caused by an attack at time point t[i] is either t
This is actually a very easy problem covered by a gaming story.\n\n**Key Observation:** The extra poison duration caused by an attack at time point `t[i]` is either the full `duration` or time increment `t[i]-t[i-1]`, whichever is smaller. \n\nSo the algorithm will become very straightforward.\n```\n    int findPoisonedDuration(vector<int>& t, int duration) {\n      int res = t.empty()? 0 : duration;\n      for (int i = 1; i < t.size(); ++i) res += min(t[i]-t[i-1], duration);\n      return res;\n    }\n```
['Array', 'C++']