Description
Submission
class Solution { using pii = pair<int, int>; public: int findMinDifference(vector<string>& timePoints) { vector<int> tps; for(auto& tp: timePoints) { int h = stoi(tp.substr(0, 2)); int m = stoi(tp.substr(3)); tps.push_back(h * 60 + m); tps.push_back((h+24) * 60 + m); } sort(tps.begin(), tps.end()); int ret = INT_MAX; for(int i = 1; i < tps.size(); ++i) { auto& tp1 = tps[i-1]; auto& tp2 = tps[i]; ret = min(ret, tp2 - tp1); } return ret; } };