diff --git a/Others/1904.The-Number-of-Full-Rounds-You-Have-Played/1904.The-Number-of-Full-Rounds-You-Have-Played.cpp b/Others/1904.The-Number-of-Full-Rounds-You-Have-Played/1904.The-Number-of-Full-Rounds-You-Have-Played.cpp index 6c1212aeb..438f8c9e4 100644 --- a/Others/1904.The-Number-of-Full-Rounds-You-Have-Played/1904.The-Number-of-Full-Rounds-You-Have-Played.cpp +++ b/Others/1904.The-Number-of-Full-Rounds-You-Have-Played/1904.The-Number-of-Full-Rounds-You-Have-Played.cpp @@ -4,16 +4,16 @@ class Solution { { vectorstart = {stoi(startTime.substr(0,2)), stoi(startTime.substr(3))}; vectorend = {stoi(finishTime.substr(0,2)), stoi(finishTime.substr(3))}; - + + if (start[0] * 60 + start[1] > end[0] * 60 + end[1]) + end[0] += 24; + start[1] = (start[1]+14) / 15 * 15; end[1] = end[1] / 15 * 15; - - int a = start[0]*60+start[1]; - int b = end[0]*60+end[1]; - - if (a > b) - b += 24*60; - - return (b-a)/15; + + int a = start[0] * 60 + start[1]; + int b = end[0] * 60 + end[1]; + + return max(0, (b-a)/15); } };