Quant Memo
Coding/●●●●●

Which trading session contains a timestamp?

A day is split into consecutive, non-overlapping sessions given only by their start minutes. Each session i covers [starts[i], starts[i+1]), and the last one runs to the end of the day.

starts = [0, 570, 1230]
labels = ["overnight", "morning", "afternoon"]
session(600)  -> "morning"     # 570 <= 600 < 1230
session(570)  -> "morning"     # left edge is inclusive
session(30)   -> "overnight"

Given a query time t, return the label of the session that contains it, in O(logn)O(\log n).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions