Community

Discussion Board

Anonymous interview experiences, offers and career talk from frontend engineers.

anon_081807

Otter AI Technical Phone screen

Google · Sr Frontend Engineer · Rejected

Rounds

OtterAI Technical phone screen

Questions asked

Problem Description
Implement a time-based key-value store class TimeRemaining where keys expire after a specified duration (in milliseconds).

Class Template
javascript
class TimeRemaining {
set(key, value, duration) {} // Adds or updates key with TTL
get(key) {} // Returns value if active, else -1
count() {} // Returns total number of active keys
}
Use code with caution.

Method Requirements
• set(key, value, duration)
• If key is new: Add it and return false.
• If key exists & active: Update it and return true.
• If key exists & expired: Update it and return false.
• get(key)
• Return the value if the key exists and is not expired.
• Return -1 if the key does not exist or has expired.
• count()
• Return the total number of unexpired keys.

Example

javascript
const timeRemaining = new TimeRemaining();

console.log(timeRemaining.set(10, 12, 1000)); // Expected: false
console.log(timeRemaining.get(10)); // Expected: 12
console.log(timeRemaining.count());

No replies yet

Markdown supported. 20 more characters needed.