Slowest Key Press
Updated
Problem statement
You are given keystrokes. Each row contains an encoded lowercase letter and its release time: [key, time]. Key 0 represents a, key 1 represents b, and key 25 represents z.
For this exercise, assume the times are cumulative release times measured from time 0, in strictly increasing order. Exactly one key is pressed at a time, and the next press begins as soon as the previous key is released. Therefore, the first press lasts keystrokes[0][1] time units; each later press lasts its release time minus the preceding row’s release time.
Return the letter whose single press lasted the longest, as a one-character string. Do not add together separate presses of the same letter. For this exercise, assume ties are resolved by returning the alphabetically larger letter.
Function
slowestKey(keystrokes: int[][]) → StringExamples
Example 1
keystrokes = [[0,2],[1,5],[0,9],[2,15]]return = "c"The individual press durations are 2, 3, 4 and 6. The c press lasts 6 time units.
Example 2
keystrokes = [[1,3],[0,6],[2,9]]return = "c"All three presses last 3 time units. The tie rule selects c.
Example 3
keystrokes = [[25,5],[0,9],[25,12]]return = "z"The first z press lasts 5 time units, longer than the later 4 and 3 time-unit presses.
Constraints
1 <= keystrokes.length <= 1000.- Every row contains exactly two integers.
0 <= keystrokes[i][0] <= 25.1 <= keystrokes[i][1] <= 10^9, and release times are strictly increasing.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Inventory Discount TrackerOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
Similar questions at other companies
- REST API: Highest International StudentsRippling · OARippling interview questions
- Count Invalid Log GroupsIBM · OAIBM interview questions
- Filter Transaction Logs and Calculate Reliability MetricsStripe · OAStripe interview questions
- Compare Character Arrays with BackspacesOdoo · OAOdoo interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Best TV Show in a GenreAdyen · OAAdyen interview questions
- Cheating CodemakerJane Street · OAJane Street interview questions
- Correct Apartment Bedroom CountsRamp · OARamp interview questions
- Reflow and Fully Justify Text LinesIntuit · OAIntuit interview questions
- Cumulative Typosquatting DetectionPalantir · OAPalantir interview questions