Skip to interview prep
Apexed

33. Find Stale Events in a Replay

EasyEvent streams

Each incoming event is [key, version]. An event is stale if that key already had an event with an equal or higher version.

Return the zero-based indexes of stale events in arrival order. A stale event does not lower the latest version.

Example 1

Input: events = [["sync",3],["other",1],["sync",1],["sync",2],["sync",4]]
Output: [2,3]

Example 2

Input: events = [["alerts",2],["alerts",2],["alerts",3]]
Output: [1]

Constraints

  • 0 ≤ events.length ≤ 100,000
  • Versions are integers in [0, 10⁹]. Keys are nonempty strings.

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs in an isolated browser sandbox. Progress and submissions are saved on this device.

Find Stale Events in a Replay — coding interview practice — Apexed