Uber·Software Engineer·Technical Phone Screen
- Design a data structure that stores revenue entries in a parent-child hierarchy. It needs two insert operations: one for top-level entries and one that links an entry to a specific parent by revenue value. At any point it should support returning the top K smallest revenues across the whole collection. Walk through your choice of underlying structures, how you handle ties, and the time complexity of each operation.
“I went with a hash map for the parent relationships and a min-heap for the top-K queries, which felt right.”