This question evaluates object-oriented design, data structure selection, and algorithmic complexity reasoning for implementing a waitlist that supports join/leave operations and top-K/bottom-K queries.
Design and implement (at the class/interface level) a waitlist system that supports the following operations:
k
users in the waitlist.
k
users in the waitlist.
userId
.
k
is larger than the queue size, return as many as possible.
Provide the main classes, methods, and the data structures you would use, along with time/space complexity and key edge cases.