Teemo Attacking
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
An attacker hits a target at the times listed in the non-decreasing array timeSeries. An attack at time t poisons the target for the inclusive interval [t, t + duration - 1], i.e. exactly duration seconds.
If a new attack lands while the target is still poisoned, the poison timer resets: the poison now ends at t + duration - 1 for the new t, and the durations do **not** stack.
Return the total number of seconds during which the target is poisoned.
Examples
Constraints
- 1 <= timeSeries.length <= 10^4
- 0 <= timeSeries[i] <= 10^7
- `timeSeries` is sorted in non-decreasing order
- 0 <= duration <= 10^7
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.