首页 > 其他 > 详细

leetcode1904 你完成的完整对局数

时间:2021-06-24 22:39:21      阅读:23      评论:0      收藏:0      [点我收藏+]

思路:

转换成分钟,方便计算。

实现:

 1 class Solution
 2 {
 3 public:
 4     int numberOfRounds(string startTime, string finishTime)
 5     {
 6         int x = stoi(startTime.substr(0, 2)) * 60 + stoi(startTime.substr(3, 2));
 7         int y = stoi(finishTime.substr(0, 2)) * 60 + stoi(finishTime.substr(3, 2));
 8         if (y < x) y += 24 * 60;
 9         y = y / 15 * 15;
10         return max(0, (y - x)) / 15;
11     }
12 };

leetcode1904 你完成的完整对局数

原文:https://www.cnblogs.com/wangyiming/p/14928333.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!