Oracle | Technical (Phone) Screen | Senior Software Engineer | USA
Summary
I had a phone screen with Oracle for a Senior Software Engineer role where I was challenged to design an event throttling mechanism, for which I provided a functional solution.
Full Experience
I recently had a phone screen with Oracle for a Senior Software Engineer role and was asked the following question:
"In a first-person shooter (FPS) game, players trigger actions like shooting, reloading, or throwing grenades by pressing keys. During intense gameplay, players may press the same key repeatedly in a short period of time, which can lead to excessive event triggers."
I was asked to design a throttling mechanism that ensures the same event type can only be triggered once within a given delay period. If the same event occurs again before the delay expires, it should be ignored. Each event type should be handled independently.
Example: delay = 5 events: [("shoot", 1), ("shoot", 2), ("reload", 3), ("shoot", 6)] output: [true, false, true, true]
This is the solution I came up with. Curious to know if there's a more optimal approach.
Interview Questions (1)
Event Throttling Mechanism for FPS Game
In a first-person shooter (FPS) game, players trigger actions like shooting, reloading, or throwing grenades by pressing keys. During intense gameplay, players may press the same key repeatedly in a short period of time, which can lead to excessive event triggers.
Design a throttling mechanism that ensures the same event type can only be triggered once within a given delay period. If the same event occurs again before the delay expires, it should be ignored. Each event type should be handled independently.
Example: delay = 5 events: [("shoot", 1), ("shoot", 2), ("reload", 3), ("shoot", 6)] output: [true, false, true, true]