1629. Slowest Key

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1629

class Solution:
    def slowestKey(self, releaseTimes: List[int], keysPressed: str) -> str:
        res = keysPressed[0]
        mx = releaseTimes[0]
        for i in range(1, len(keysPressed)):
            d = releaseTimes[i] - releaseTimes[i - 1]
            if d > mx or (d == mx and ord(keysPressed[i]) > ord(res)):
                mx = d
                res = keysPressed[i]
        return res