Engineers have redesigned a keypad used by ambulance drivers in urban areas. In order to determine which key takes the longest time to press, the keypad is tested by a driver. Given the results of that test, determine which key takes the longest to press.
Function Description
Complete the function slowestKey
in the editor below.
slowestKey
has the following parameter(s):
int keyTimes[n][2]
: the first column contains the encoded key pressed, the second
𓆝 ⋆.𖦹°‧🫧𓂃Credit to ㄇE𓈒𓇼 ⋆。˚ 𓆝
Example 1:
Input: keyTimes = [[0, 2], [1, 5], [0, 9], [2, 15]]
Output: c
Explanation:Elements in
keyTimes[i][0]
represent encoded characters in the range ascii[a-z] where a = 0, b = 1, ... z = 25. The second element,keyTimes[i][1]
represents the time the key is pressed since the start of the test. The elements will be given in ascending time order. In the example, keys pressed, in order are 0[2/encoded] = abcat times 2, 5, 9, 15. From the start time, it took 2 - 0 = 2 to press the first key, 5 - 2 = 3 to press the second, and so on. The longest time it took to press a key was key 2, or 'c', at 15 - 9 = 6.
n/a

input:
output: