当前位置:网站首页>剑指 Offer II 035. 最小时间差
剑指 Offer II 035. 最小时间差
2022-06-25 16:35:00 【Python ml】
def getMinutes(t:str)->int:
return ((ord(t[0])-ord('0'))*10+ord(t[1])-ord('0'))*60+(ord(t[3])-ord('0'))*10+ord(t[4])-ord('0')
class Solution:
def findMinDifference(self, timePoints: List[str]) -> int:
n=len(timePoints)
if n>1440: return 0
timePoints.sort()
ans=float('inf')
t0Minutes=getMinutes(timePoints[0])
preMinutes=t0Minutes
for i in range (1,n):
curMinutes=getMinutes(timePoints[i])
ans=min(ans,curMinutes-preMinutes)
preMinutes=curMinutes
ans=min(ans,t0Minutes+1440-curMinutes)
return ans
边栏推荐
- SDN系统方法 | 10. SDN的未来
- Redis series - overview day1-1
- 千万级购物车系统缓存架构方案
- Day_ fourteen
- Vscode plug-in self use
- 論文筆記:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm
- Android修行手册之Kotlin - 自定义View的几种写法
- Problems encountered in using MySQL
- Knowing these interview skills will help you avoid detours in your test job search
- MySQL_ JDBC
猜你喜欢
随机推荐
[100 questions of Blue Bridge Cup intensive training] scratch command mobile Blue Bridge Cup scratch competition special prediction programming question intensive training simulation exercise question
Batch --07--- breakpoint lifting
Redis series - overview day1-1
解析数仓lazyagg查询重写优化
协议和分层次
论文笔记:Generalized Random Forests
Bombard the headquarters. Don't let a UI framework destroy you
Day_ fifteen
Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-外力ExternalForces
批量--07---断点重提
效应与定律
redis 分布式锁整理
Xinlou: un voyage de sept ans de Huawei Sports Health
Optimization of lazyagg query rewriting in parsing data warehouse
Knowing these interview skills will help you avoid detours in your test job search
JVM内存结构
A TDD example
Wireshark网卡无法找到或没有显示的问题
Day_ seventeen
DDD概念复杂难懂,实际落地如何设计代码实现模型?









