Skip to content

Instantly share code, notes, and snippets.

@freelze
Last active September 21, 2017 09:24
Show Gist options
  • Save freelze/cc3ac456c08ff25f246e6fa3894fddee to your computer and use it in GitHub Desktop.
Save freelze/cc3ac456c08ff25f246e6fa3894fddee to your computer and use it in GitHub Desktop.
Runtime: 59 ms , Your runtime beats 76.14 % of cpp submissions.(2017/9/21)
class Solution {
public:
int findPoisonedDuration(vector<int>& ts, int dur) {
unsigned int temp=0;
for(int i=0;i < (int)ts.size()-1 ; i++){
if( (int)dur-ts[i+1]+ts[i] > 0)
temp+=(int)dur-ts[i+1]+ts[i];
}
return (int)dur*ts.size()-temp;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment