PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Software Engineering Fundamentals/Google

Design a multi-timer using single underlying timer

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to implement timer scheduling, resource multiplexing, and concurrency control using constrained system primitives, testing understanding of timers, event handling, data structures, and correctness under race conditions.

  • medium
  • Google
  • Software Engineering Fundamentals
  • Software Engineer

Design a multi-timer using single underlying timer

Company: Google

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Take-home Project

You are given a `Timer` class that has access to a *single* underlying system timer API that can only keep **one active timer at a time**. ### Underlying single-timer primitives (already available) ```java class Timer { // Schedule ONE timer to fire at `timestamp` (absolute time). // If called again, it overrides/cancels the previously scheduled system timer. private void setTimer(long timestamp); // Called automatically when the currently scheduled system timer expires. private void handleTimer(); // Returns current time as an absolute timestamp (same unit as setTimer). private long getCurrentTime(); // Public API: users can call this to schedule MANY timers. public void setNewTimer(long timestamp); } ``` ### Requirements - Users can only call `setNewTimer(timestamp)`. - `setNewTimer` must support **multiple** outstanding timers. - When any user timer expires, `handleTimer()` should be invoked (once per expired user timer). - You must implement the logic of the four methods so that multiple user timers are correctly managed on top of the single underlying `setTimer`. ### Clarifications you may assume - `timestamp` is an **absolute** time value (e.g., epoch milliseconds) comparable to `getCurrentTime()`. - Multiple user timers may share the same timestamp. - If a timer is set for a time ≤ `getCurrentTime()`, it should fire “immediately” (as soon as the system can schedule it). Discuss data structures, time/space complexity, and important edge cases (e.g., overrides, duplicate timestamps, and concurrency if relevant).

Quick Answer: This question evaluates a candidate's ability to implement timer scheduling, resource multiplexing, and concurrency control using constrained system primitives, testing understanding of timers, event handling, data structures, and correctness under race conditions.

Related Interview Questions

  • Process Sharded Login Logs - Google (medium)
  • Design an ads retrieval service using a heap - Google (easy)
  • Design a waitlist manager - Google (easy)
  • Design an editable sequence with marker - Google (medium)
  • Design a waitlist system with top/bottom K - Google (medium)
Google logo
Google
Dec 4, 2025, 12:00 AM
Software Engineer
Take-home Project
Software Engineering Fundamentals
6
0

You are given a Timer class that has access to a single underlying system timer API that can only keep one active timer at a time.

Underlying single-timer primitives (already available)

class Timer {
  // Schedule ONE timer to fire at `timestamp` (absolute time).
  // If called again, it overrides/cancels the previously scheduled system timer.
  private void setTimer(long timestamp);

  // Called automatically when the currently scheduled system timer expires.
  private void handleTimer();

  // Returns current time as an absolute timestamp (same unit as setTimer).
  private long getCurrentTime();

  // Public API: users can call this to schedule MANY timers.
  public void setNewTimer(long timestamp);
}

Requirements

  • Users can only call setNewTimer(timestamp) .
  • setNewTimer must support multiple outstanding timers.
  • When any user timer expires, handleTimer() should be invoked (once per expired user timer).
  • You must implement the logic of the four methods so that multiple user timers are correctly managed on top of the single underlying setTimer .

Clarifications you may assume

  • timestamp is an absolute time value (e.g., epoch milliseconds) comparable to getCurrentTime() .
  • Multiple user timers may share the same timestamp.
  • If a timer is set for a time ≤ getCurrentTime() , it should fire “immediately” (as soon as the system can schedule it).

Discuss data structures, time/space complexity, and important edge cases (e.g., overrides, duplicate timestamps, and concurrency if relevant).

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Google•More Software Engineer•Google Software Engineer•Google Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.