slowestKey
to the first key in keysPressed
and longestPress
to releaseTimes[0]
.releaseTimes
starting from the second element.currentDuration
as the difference between the current and previous releaseTimes
.currentDuration
is greater than longestPress
, update slowestKey
and longestPress
.currentDuration
is equal to longestPress
and the current key is lexicographically larger than slowestKey
, update slowestKey
.slowestKey
after the iteration is complete.