当前位置:网站首页>Sword finger offer II 035 Minimum time difference
Sword finger offer II 035 Minimum time difference
2022-06-25 17:04:00 【Python ml】
The finger of the sword Offer II 035. Minimum time difference
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
边栏推荐
- 居家办公让我绩效拿了C | 社区征文
- 千万级购物车系统缓存架构方案
- mood
- 计网 | 形象理解路由协议RIP、OSPF、BGP
- Ad domain login authentication
- Mac PHP multi version management and swoole extension installation
- STM32硬件错误HardFault_Handler的处理方法
- Will the 2022 cloud world be better
- The problem of missing precision of kettle table input components
- How did I raise my salary to 20k in three years?
猜你喜欢

Singleton mode application

Xshell connecting VMware virtual machines

Kalman time series prediction

3年,我是如何涨薪到20k?

二十九-使用RealSenseD435进行ORBSLAM2实时三维重建

Babbitt yuan universe daily recommendation: three players holding "tens of millions" of collections have revealed the "three routines" of the digital collection market

芝士糖豆打造AR潮玩新体验

Protocol and hierarchy

Using pywebio testing, novice testers can also make their own testing tools

PLSQL 存储函数SQL编程
随机推荐
巴比特 | 元宇宙每日荐读:三位手握“价值千万”藏品的玩家,揭秘数字藏品市场“三大套路”...
Vscode plug-in self use
This latest research has revealed two secrets of cloudy development
pychrm的这些配置,你都知道吗?
3年,我是如何涨薪到20k?
Protocol and hierarchy
从业一年,我是如何涨薪13K+?
Tensorflow old version
Next.js 热更新 Markdown 文件变更
芝士糖豆打造AR潮玩新体验
足下教育日精进自动提交
组件通讯的方式有哪些
Optimization of lazyagg query rewriting in parsing data warehouse
3. conditional probability and independence
远程终端控制神器——MobaXterm
2022-06-17 advanced network engineering (x) is-is-general header, establishment of adjacency relationship, IIH message, DIS and pseudo node
Redis系列——概述day1-1
SDN系统方法 | 10. SDN的未来
Uniapp to preview pictures (single / multiple)
Redis 的PSYNC命令