Implement a system that:
YYYY-MM-DD format; month is YYYY-MM.void rateAgent(String agentName, int rating, String date)
agentName: non-blank agent identifier.rating: integer in [1, 5].date: rating date in "YYYY-MM-DD" format.List<String> getAverageRatings()
"agentName,averageRating" (e.g., "Bob,4.5").averageRating.List<String> getBestAgentsByMonth(String month)
month: month string in "YYYY-MM" format (e.g., "2025-03")."agentName,averageRating".averageRating for that month.Input:
rateAgent("Alice", 5, "2025-03-12")
rateAgent("Bob", 4, "2025-03-13")
rateAgent("Alice", 3, "2025-03-15")
rateAgent("Bob", 5, "2025-03-18")
getAverageRatings()
Output:
[
"Bob,4.5",
"Alice,4.0"
]
Explanation:
Bob → (4 + 5) / 2 = 4.5
Alice → (5 + 3) / 2 = 4.0
Sorted from highest to lowest average rating.
Input:
rateAgent("Alice", 5, "2025-02-02")
rateAgent("Bob", 3, "2025-02-05")
rateAgent("Charlie", 4, "2025-02-10")
rateAgent("Bob", 5, "2025-03-12")
rateAgent("Alice", 2, "2025-03-15")
getBestAgentsByMonth("2025-02")
Output:
[
"Alice,5.0",
"Charlie,4.0",
"Bob,3.0"
]
Explanation:
Only ratings with dates in February 2025 are considered.
Agents are ordered from highest to lowest average rating for that month.