Skip to content

Practice Button with Longest Push Time

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3386
LeetCode Problem

Button with Longest Push Time

Problem Statement

The events [index, time] arrive in increasing time order. The duration of the first button press is its time; each later duration is its time minus the previous event’s time. Return the button index with the longest single press duration, breaking tied durations by the smallest index.

Source: Button with Longest Push Time on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
events = [[1,2],[2,5],[3,9],[1,15]]
Output
1

# Example 2

Input
events = [[10,5],[1,7]]
Output
10

Constraints

1 <= events.length <= 1000
events[i] == [indexi, timei]
1 <= indexi, timei <= 10^5
The input is generated such that events is sorted in increasing order of timei.

Related LeetCode Problems

Practice more problems similar to Button with Longest Push Time.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.