class Solution {
private:
int toInt(conststring &s) {
char c; int h, m;
stringstream ss(s);
ss >> h >> c >> m;
return h * 60 + m;
}
public:
int findMinDifference(vector<string>& timePoints) {
vector<int> vec;
int ret = INT_MAX;
for (auto &t: timePoints) vec.push_back(toInt(t));
sort(vec.begin(), vec.end());
//vec.push_back(vec.front());for (auto v: vec) cout << v << " "; cout << endl;
for (int i = 1; i < vec.size(); i++) {
int val = vec[i] - vec[i - 1];
ret = min(ret, val);
}
ret = min(ret, vec.back() - vec.front());
ret = min(ret, (1440 + vec.front() - vec.back()) % 1440);
return ret;
}
};
539. Minimum Time Differenceclass Solution {private: int toInt(const string &s) { char c; int h, m; stringstream ss(s); ss >> h >> c >> m; return h * 60 + m; }