leetcode:按键持续时间最长的键

leetcode:按键持续时间最长的键
代码:

class Solution:
    def slowestKey(self, releaseTimes: List[int], keysPressed: str) -> str:
        res = ''
        lastTime = 0
        maxDuration = -1
        for i in range(len(releaseTimes)):
            duration = releaseTimes[i] - lastTime
            if duration > maxDuration:
                maxDuration = duration
                res = keysPressed[i]
            elif duration == maxDuration and res < keysPressed[i]:
                res = keysPressed[i]
            lastTime = releaseTimes[i]
        return res
上一篇:tomcat install on Linux


下一篇:c11 storage-class specifiers 存储类型指示符