
You are given two coding tasks.
Design an in-memory data structure that supports:
set(key, value, timestamp)
: store the string
value
for string
key
at integer
timestamp
.
get(key, timestamp) -> value
: return the value associated with
key
at the largest stored timestamp
t
such that
t <= timestamp
. If there is no such timestamp (or
key
was never set), return an empty string.
Notes / assumptions
set
operations may occur for the same
key
at different timestamps.
set
calls for a given key arrive in non-decreasing timestamp order unless stated otherwise.
You are given schedules for N people. Each person’s schedule is a list of busy time intervals during the day.
[start, end)
with
start < end
.
Return all time intervals (also as [start, end)) when everyone is available (i.e., when no one is busy). Only include intervals with positive length.
Clarify in your solution
[0, 24*60)
minutes) and how to handle availability outside provided busy intervals.
schedules: List[List[Interval]]
, where
schedules[i]
is person
i
’s busy intervals.
List[Interval]
representing common free time intervals.