Snap·Software Engineer·Technical Phone Screen
- Design a data structure that supports two operations: one that records a strictly increasing integer timestamp, and one that returns how many recorded timestamps are strictly greater than a given value. Then discuss the trade-offs between different designs that optimize for different access patterns.
“I went straight for the obvious approach, store timestamps in a list, binary search on query, O(1) write and O(log n) read.”