← 返回 atlassian 的题目列表Agent Rating Average Ranking
类型:qbank
Implement a rating service for support agents or customer-service reps. The core APIs accept 1-5 ratings and return agents sorted by average rating; follow-ups focus on tie-breaking and maintaining the ranking efficiently across repeated calls.
Requirements
Support recording a rating for an agent/customer-service representative. Ratings are in the 1-5 range.
Return all agents sorted by average rating from high to low.
Track enough state to compute average rating incrementally, typically total score plus count per agent.
Follow-ups include:
Define and implement a deterministic tie-break when two agents have the same average.
Maintain the ranking when getTopAgents() is called repeatedly.
Discuss whether a priority queue, balanced tree, binary-search insertion, or full sort is appropriate.
Notes
Brute-force sorting on every read can pass the base implementation, but interviewers may push on why a priority queue can be awkward when every read needs the full ordered list.
Clarify whether updating an existing agent's average must immediately update the global order and whether output should include all agents or only top K.
Preparation
Write a simple rateAgent(name, score) / getTopAgents() implementation first, then optimize read-heavy and write-heavy cases separately.
Prepare a tie-break policy, such as name, first rating time, or total rating count, and state it before coding.