# [539. Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference/description) :::spoiler Hint ```cpp= ``` ::: :::spoiler Solution ```cpp= class Solution { public: int findMinDifference(vector<string>& timePoints) { int n = timePoints.size(); vector<int> minutes(n); for (int i = 0; i < n; i++) { int h = stoi(timePoints[i].substr(0, 2)); int m = stoi(timePoints[i].substr(3)); minutes[i] = (h * 60 + m); } sort(minutes.begin(), minutes.end()); int res = 1440; for (int i = 0; i < n - 1; i++) { res = min(res, minutes[i + 1] - minutes[i]); } return min(res, 24 * 60 - (minutes[n - 1] - minutes[0])); } }; ``` - T: $O()$ - S: $O()$ :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up