Slowest Key Press
Problem statement
You are given keystrokes. Each row contains an encoded lowercase letter and its release time: [key, time]. Key 0 represents a, key 1 represents b, and key 25 represents z.
For this exercise, assume the times are cumulative release times measured from time 0, in strictly increasing order. Exactly one key is pressed at a time, and the next press begins as soon as the previous key is released. Therefore, the first press lasts keystrokes[0][1] time units; each later press lasts its release time minus the preceding row’s release time.
Return the letter whose single press lasted the longest, as a one-character string. Do not add together separate presses of the same letter. For this exercise, assume ties are resolved by returning the alphabetically larger letter.
Function
slowestKey(keystrokes: int[][]) → StringExamples
Example 1
keystrokes = [[0,2],[1,5],[0,9],[2,15]]return = "c"The individual press durations are 2, 3, 4 and 6. The c press lasts 6 time units.
Example 2
keystrokes = [[1,3],[0,6],[2,9]]return = "c"All three presses last 3 time units. The tie rule selects c.
Example 3
keystrokes = [[25,5],[0,9],[25,12]]return = "z"The first z press lasts 5 time units, longer than the later 4 and 3 time-unit presses.
Constraints
1 <= keystrokes.length <= 1000.- Every row contains exactly two integers.
0 <= keystrokes[i][0] <= 25.1 <= keystrokes[i][1] <= 10^9, and release times are strictly increasing.