代码:
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