当前位置:网站首页>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
边栏推荐
猜你喜欢

好胖子带你学Flink系列-Flink源码剖析第一集Standalone启动脚本分析

批量--07---断点重提

FreeRTOS内核时钟不对的问题解决

剑指 Offer 39. 数组中出现次数超过一半的数字

Redis系列——概述day1-1

【機器學習】基於多元時間序列對高考預測分析案例

2022-06-17 网工进阶(九)IS-IS-原理、NSAP、NET、区域划分、网络类型、开销值

App测试工具大全,收藏这篇就够了

Pytorch official document learning record

Wireshark network card cannot be found or does not display the problem
随机推荐
Ad domain login authentication
心情
深入浅出对话系统——自己实现Transformer
万卷书 - 大力娃的书单
try with resource
[Jianzhi offer II 091. painting the house]
FreeRTOS内核时钟不对的问题解决
SMART PLC如何构造ALT指令
Ncnn source code learning collection
Simple dialogue system -- implement transformer by yourself
How do components communicate
Kotlin
Pytorch official document learning record
Sword finger offer 50 First character that appears only once
旧手机变废为宝,充当服务器使用
JVM memory structure
IO stream
【微服务|Sentinel】流控规则概述|针对来源|流控模式详解<直接 关联 链路>
记一次基于PHP学生管理系统的开发
TCP聊天+传输文件服务器服务器套接字v2.8 - 修复已知程序4个问题