Description

A newly designed keypad was tested. Given the times taken to press each key, return the key of the slowest press. If tied, return lexicographically largest.

Examples

Input:releaseTimes = [9,29,49,50], keysPressed = "cbcd"
Output:"c"
Explanation:

c took 20 units (longest).

Input:releaseTimes = [12, 23, 36, 58, 58], keysPressed = "abadd"
Output:d
Explanation:

Press durations: a=12, b=11, a=13, d=22, d=0. Both 'a' (13 units) and 'd' (22 units) are pressed multiple times, but 'd' has the longest single press of 22 units.

Input:releaseTimes = [15, 32, 48], keysPressed = "xyz"
Output:"y"
Explanation:

Press durations: x=15, y=32-15=17, z=48-32=16. Key 'y' has the longest press duration of 17 units.

Constraints

  • releaseTimes.length == keysPressed.length

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!