#3386

Button with Longest Push Time

pupil · 520 · lc easy +28 · 41% accepted · 77 likes · top 21%

Description

You are given a 2D array events representing a sequence of button presses on a keyboard.

Each events[i] = [indexi, timei] indicates the button at index indexi was pressed at time timei.

- The array is sorted by increasing time.

- The time taken to press a button equals the gap between consecutive presses. The first button's press time is simply its recorded time.

Return the index of the button that required the longest press. Break ties in favor of the smaller index.

Code

1
2
3