The Button with Longest Push Time interview question asks you to process a series of timestamps from a keypad. You are given a 2D array logs where each entry is [button_index, time_released]. Each button is pushed one after another. The "push time" for a button is the difference between its release time and the release time of the previous button. For the first button, the push time is simply its release time. You need to find the button with the maximum push time. This Button with Longest Push Time coding problem is a fundamental array iteration task.
Companies like J.P. Morgan and Amazon use this as an entry-level coding task. it tests basic loop logic, state tracking (storing the previous release time), and tie-breaking conditions (usually returning the smallest index if multiple buttons have the same longest time). It ensures a candidate has the basic syntax and logic skills required for backend development.
This utilizes the Array interview pattern. It's a simple linear scan where you maintain:
Logs: [[1, 5], [2, 12], [1, 15]]
Always pay close attention to "tie-breaker" requirements in "find the max/min" problems. Often, the problem specifies returning the smallest index or the first occurrence, which changes your comparison logic from > to >= or requires an extra if condition.