Slowest Key
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A tester typed a sequence of n keys, one at a time. keysPressed[i] is the i-th key, and releaseTimes[i] is the moment it was released. The first key was pressed at time 0, and each later key was pressed exactly when the previous one was released.
So key i was held for releaseTimes[0] if i == 0, and releaseTimes[i] - releaseTimes[i - 1] otherwise. The same key may be typed several times; each press is measured separately.
Return the key (a single character) with the longest single press. If several presses tie for longest, return the lexicographically largest of those keys.
Examples
Constraints
- n == releaseTimes.length == keysPressed.length
- 2 <= n <= 1000
- 1 <= releaseTimes[i] <= 10^9
- releaseTimes[i] < releaseTimes[i + 1]
- `keysPressed` contains only lowercase English letters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.